<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-build-a-tool-server-and-connect-an-agent-to-it-hr2km0zqm" -->

---
title: How to Build a Tool Server and Connect an Agent to It
description: A beginner-friendly walkthrough on building an MCP (Model Context Protocol) tool server in Python and connecting an AI agent to it. Covers setting up a Python...
canonical: https://daily.dev/posts/how-to-build-a-tool-server-and-connect-an-agent-to-it-hr2km0zqm
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Build a Tool Server and Connect an Agent to It | daily.dev
og:description: A beginner-friendly walkthrough on building an MCP (Model Context Protocol) tool server in Python and connecting an AI agent to it. Covers setting up a Python...
og:url: https://daily.dev/posts/how-to-build-a-tool-server-and-connect-an-agent-to-it-hr2km0zqm
og:image: https://api.daily.dev/og/posts/Hr2Km0Zqm.png
og:image:alt: How to Build a Tool Server and Connect an Agent to It
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Build a Tool Server and Connect an Agent to It

**[Medium](https://daily.dev/sources/medium_js)** · 8 min read · 0 upvotes · 0 comments

## Summary

A beginner-friendly walkthrough on building an MCP (Model Context Protocol) tool server in Python and connecting an AI agent to it. Covers setting up a Python 3.11 environment, creating a FastMCP server with tool functions, and writing an agent client that auto-discovers and calls those tools via OpenAI's GPT-4o. The key demonstration shows how adding a new tool to the server requires zero changes to the agent code, illustrating MCP's plug-and-play value proposition.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://here2serveyou.medium.com/how-to-build-a-tool-server-and-connect-an-agent-to-it-714882c03a81>

## Questions this post answers

### Why does installing the MCP Python SDK fail with a Rust build error on Python 3.13?

The MCP Python SDK depends on PyO3, a set of Rust bindings that does not yet support Python 3.12 or newer, so installing on Python 3.12, 3.13, or 3.14 triggers a long, confusing Rust build error. Using Python 3.11 specifically avoids this problem entirely before starting any MCP project setup.

_Anyone hitting Rust build errors while installing MCP tooling can find version-compatibility fixes on daily.dev._

### How do I let an AI agent discover new tools without changing the agent's code?

Add the new tool function to the MCP server file with the @mcp.tool() decorator and a clear docstring describing what it does; the agent calls session.list_tools() at connection time to automatically discover any tools the server exposes. Because tool discovery happens dynamically, adding a second tool like packing_advice requires zero changes to the separate agent script.

_Developers wiring up extensible agent tooling track patterns like MCP's dynamic tool discovery on daily.dev._

### What is the difference between an MCP server and an MCP client?

An MCP server represents the tool side, exposing what it can do and how to call it, while an MCP client represents the agent side, asking the server what capabilities exist and then requesting execution of a specific one. This one agreed-upon interface lets any tool plug into any compatible agent without custom integration code for each pairing.

_Engineers evaluating MCP against custom tool-wiring approaches compare architectures like this on daily.dev._

## Similar posts on daily.dev

- [How to Build an MCP Server with FastMCP for Your Local AI Agent](https://daily.dev/posts/how-to-build-an-mcp-server-with-fastmcp-for-your-local-ai-agent-rtwnypgfj) · freeCodeCamp · 2 upvotes · 0 comments
- [How to Build Your Own MCP Server with Python](https://daily.dev/posts/how-to-build-your-own-mcp-server-with-python-9azzt16xk) · freeCodeCamp · 4 upvotes · 0 comments
- [MCP Explained: How Modern AI Agents Connect to the Real World](https://daily.dev/posts/mcp-explained-how-modern-ai-agents-connect-to-the-real-world-tvdsyp4oi) · Towards Data Science · 5 upvotes · 1 comments
- [How to Use MCP with OpenAI Agents](https://daily.dev/posts/how-to-use-mcp-with-openai-agents-v01uepcgd) · DigitalOcean Community · 0 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#ai-agents](https://daily.dev/tags/ai-agents), [#openai](https://daily.dev/tags/openai), [#mcp](https://daily.dev/tags/mcp)

[View this post on daily.dev](https://daily.dev/posts/how-to-build-a-tool-server-and-connect-an-agent-to-it-hr2km0zqm)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to Build a Tool Server and Connect an Agent to It","url":"https://daily.dev/posts/how-to-build-a-tool-server-and-connect-an-agent-to-it-hr2km0zqm","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-build-a-tool-server-and-connect-an-agent-to-it-hr2km0zqm"},"datePublished":"2026-07-18T01:17:28.227Z","dateModified":"2026-09-14T06:25:28.210Z","description":"A beginner-friendly walkthrough on building an MCP (Model Context Protocol) tool server in Python and connecting an AI agent to it. Covers setting up a Python...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/eb8c04c43d0617b8f0fac147f28a252a?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/eb8c04c43d0617b8f0fac147f28a252a?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-build-a-tool-server-and-connect-an-agent-to-it-hr2km0zqm","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,ai-agents,openai,mcp","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"How to Build a Tool Server and Connect an Agent to It"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-build-a-tool-server-and-connect-an-agent-to-it-hr2km0zqm#faq","mainEntity":[{"@type":"Question","name":"Why does installing the MCP Python SDK fail with a Rust build error on Python 3.13?","acceptedAnswer":{"@type":"Answer","text":"The MCP Python SDK depends on PyO3, a set of Rust bindings that does not yet support Python 3.12 or newer, so installing on Python 3.12, 3.13, or 3.14 triggers a long, confusing Rust build error. Using Python 3.11 specifically avoids this problem entirely before starting any MCP project setup. Anyone hitting Rust build errors while installing MCP tooling can find version-compatibility fixes on daily.dev."}},{"@type":"Question","name":"How do I let an AI agent discover new tools without changing the agent's code?","acceptedAnswer":{"@type":"Answer","text":"Add the new tool function to the MCP server file with the @mcp.tool() decorator and a clear docstring describing what it does; the agent calls session.list_tools() at connection time to automatically discover any tools the server exposes. Because tool discovery happens dynamically, adding a second tool like packing_advice requires zero changes to the separate agent script. Developers wiring up extensible agent tooling track patterns like MCP's dynamic tool discovery on daily.dev."}},{"@type":"Question","name":"What is the difference between an MCP server and an MCP client?","acceptedAnswer":{"@type":"Answer","text":"An MCP server represents the tool side, exposing what it can do and how to call it, while an MCP client represents the agent side, asking the server what capabilities exist and then requesting execution of a specific one. This one agreed-upon interface lets any tool plug into any compatible agent without custom integration code for each pairing. Engineers evaluating MCP against custom tool-wiring approaches compare architectures like this on daily.dev."}}]}
```

