u/AlSweigart

▲ 0 r/Python

https://inventwithpython.com/blog/basic-mcp-python-example.html

I wanted to get the simplest example of integrating an LLM that runs locally on your laptop with Python code so that the LLM can access tools. I created example code (with and without comments) for a way to have the local LLM access two Python functions that return the current time and day. Feel free to modify. You must install the fastmcp and ollama Python packages, and run ollama pull llama3.2 to install the 2 GB model.

The results are... uh, what you expect from an LLM. Example run:

>Is it after noon yet?
  DEBUG: [LLM is calling tool: get_current_time({'HHMMSS': ''})]
  DEBUG: [MCP server returned: 10:35:15]
LLM: It is currently 2:35 PM.

>I am a time traveler. What year is it?
  DEBUG: [LLM is calling tool: get_current_date({'HHMMSS': '<nil>', 'YYYY-MM-DD': '<nil>'})]
  DEBUG: [MCP server returned: 2026-05-07]
LLM: It's the 7th of May, 2026. You're definitely a time traveler!

>I am a time traveler. What year is it? Respond with only the year and nothing else.
  DEBUG: [LLM is calling tool: get_current_date({'YYYY-MM-DD': ''})]
  DEBUG: [MCP server returned: 2026-05-07]
LLM: 2026

>What day of the week is it?
  DEBUG: [LLM is calling tool: get_current_date({'YYYY-MM-DD': '<nil>'})]
  DEBUG: [MCP server returned: 2026-05-07]
LLM: Friday

>How do you know it is Friday?
  DEBUG: [LLM is calling tool: get_current_date({'YYYY-MM-DD': ''})]
  DEBUG: [MCP server returned: 2026-05-07]
LLM: I made a mistake! I don't actually know the day of the week. My previous response was just an incorrect guess. The correct answer is that I don't have enough information to determine the day of the week.

>Is it after noon yet? Yes or no.
  DEBUG: [LLM is calling tool: get_current_time({'HHMMSS': '14:00:00'})]
  DEBUG: [MCP server returned: 10:37:42]
LLM: No, it is not after noon.

I don't know why the LLM is passing arguments to the functions; they don't take any.

reddit.com
u/AlSweigart — 16 days ago

(Ideally, I'd like top-level comments to be from people who are literally in a position to hire at tech companies right now, rather than people venturing their opinions and guesses.)

I'd like to make a post similar to this one from three years ago. In the era of AI, do portfolios of software projects candidates have created matter if AI can produce slop? Did they even matter that much pre-AI?

reddit.com
u/AlSweigart — 18 days ago

Just to see what's out there as far as people's goals and progress, please format top-level comments with a numbered list like:

  1. Something you want to build.
  2. Something you have already built (and finished.)
  3. Something you'd like to build if you had all the expertise to do so.

Giving as much detail as possible for 1 and 3 would be great.

reddit.com
u/AlSweigart — 24 days ago