Tool Server Python
No description available
Ask AI about Tool Server Python
Powered by Claude ยท Grounded in docs
I know everything about Tool Server Python. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
๐งฎ MCP Tool Server Python (FastMCP)
A robust, modular, and fully functional example of building a Model Context Protocol (MCP) server using Python and the fastmcp library. This project serves as an excellent foundation for understanding how to expose simple tools via the MCP protocol and intuitively interact with them using an MCP client.
๐ฏ Architecture Overview
The codebase is organized neatly to mimic a production environment, separating server logic from client execution:
mcp-tool-server-python/
โโโ src/
โ โโโ __init__.py
โ โโโ server.py # Defines the FastMCP Server and registers tools
โ โโโ client.py # Instantiates the Client and runs interactions
โโโ main.py # Application entry point
โโโ requirements.txt # Project dependencies
โโโ .gitignore
โโโ README.md
โจ Key Features
- Nested & Modular Setup: Clean architecture separating
serverdependencies fromclientexecution. - Dynamic Tool Discovery: Clients can query the server at runtime to learn which tools and schemas are available.
- Type-hinted Definitions: Tools strictly rely on Python's native type hinting (
a: int, b: int) allowing automatic schema generation. - Async Execution: Asynchronous core flow using
asynciofor non-blocking operations.
๐ Required Prerequisites
- Python 3.9+ installed natively or within a Conda/Virtual environment.
- Git (for cloning this repository)
๐ Quickstart Guide
1. Clone the Repository
git clone https://github.com/Mukkandi-Sridhar/mcp-tool-server-python.git
cd mcp-tool-server-python
2. Install Dependencies
It's recommended to utilize a virtual environment:
python -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate
Install the required library (fastmcp):
pip install -r requirements.txt
3. Run the Application
Execute the main.py directly. This will invoke the client, which in turn spins up the server, discovers registered tools, and executes test mathematical operations.
python main.py
๐ป Expected Output
Upon successful execution, the terminal will dynamically list registered tools and provide accurate mathematical outputs:
Available tools:
- add
- subtract
Add Result: 15
Subtract Result: 7
๐ง What's Next? (Scaling for AI Agent Roles)
To turn this into an industry-grade LLM project, you can easily expand the src/server.py file to attach real-world logic inside the @mcp.tool definitions:
- Database/Vector Search Tools: Querying PostgreSQL / Pinecone for internal documents.
- Web Browsing Agents: Passing URL fetching abilities to an LLM.
- File System Readers: Parsing local PDF or configuration files.
๐ License
This codebase is released under the MIT License. Feel free to use it for personal applications or expand it for production workflows.
