Supports loading configuration values from .env files, allowing server settings to be defined in environment variables stored in the project's root directory
Built entirely in Python, allowing for easy extension by defining tools as decorated Python functions that can be hot-reloaded without server restart
PyMCP
PyMCP is a simple, tiny, and asynchronous server and client implementation for the Modern Context Protocol (MCP).
Features
- Simple Tool Definition: Easily expose functions as remote tools using a simple
@tool
decorator. - Hot-Reloading: Tools can be added, removed, or modified on the fly, and the server will hot-reload them without a restart.
Quick Start
Running the Server
- Installation (from source):
- Run the Server:
- run with default settings:
- run with custom settings:
Using the Client
Configuration
- Arguments passed to start_server().
- Command-line arguments (e.g., --port).
- Environment variables (e.g., PYMCP_PORT=9000).
- Values in a .env file in your project's root.
- Default values in the Settings class.
all configuration options:
Server
request->response flow
create a tool
Tool Repository discovery
The server discovers tools by scanning all .py
files within the directories specified by the --tool-repo
CLI argument or the PYMCP_TOOL_REPOS
environment variable.
You can organize your tools into multiple files and directories. The loader will scan them recursively.
example directory structure:
Hot-Reloading
The server watches the tool repositories for file changes. If you add, modify, or delete a Python file in a tool directory, the server will automatically perform a reload:
- It rebuilds the entire tool registry from scratch.
- It atomically swaps the old registry with the new one.
This allows you to update tool logic on a live server without a restart.
PyMCP supports a simple form of dependency injection. If a tool function's signature includes a parameter named tool_registry
, the server will automatically provide the ToolRegistry
instance to it at execution time.
Client
Connect to the server
request execute tools
Protocol
PyMCP uses a simple, JSON-based messaging protocol over a standard WebSocket connection.
- Client-to-Server: Requests
- Server-to-Client: Responses (Success)
- Server-to-Client: Responses (Error)
Design
PyMCP is designed to be simple, extensible, and easy to use. The server itself is just a WebSocket server that handles incoming requests, validates them, routes them to the appropriate tool executor, and returns the results.
No concept like "resources", "tools", or "prompts", since all of them are just a function that input something and return something. Everything is a tool. It leaves to user defining the scope of the tools.
The internal tools like list_tools_available
and ping
, are also some type of "tools". Tools and Server are decoupled. core tools are like extension of the server.
This server cannot be installed
A simple, tiny, and asynchronous server and client implementation for the Modern Context Protocol that allows you to easily expose functions as remote tools using a decorator with hot-reloading capability.
Related MCP Servers
- -securityAlicense-qualityA simple implementation of a Model Context Protocol server that demonstrates core functionality including mathematical tools (add, subtract) and personalized greeting resources.Last updated -56PythonGPL 3.0
- -securityFlicense-qualityA sample implementation of Model Context Protocol server demonstrating core functionality with simple arithmetic tools and greeting resources.Last updated -Python
- AsecurityAlicenseAqualityA comprehensive Model Context Protocol server providing access to 70+ IT tools for developers and system administrators, including encoding/decoding, text manipulation, hashing, and network utilities.Last updated -764006TypeScriptMIT License
- AsecurityFlicenseAqualityA Model Context Protocol server implementation that provides basic utility tools including echo, uppercase text conversion, and mathematical calculations.Last updated -3738JavaScript