A robust, extensible Model Context Protocol (MCP) server template for building tool-based automation APIs. Easily add, expose, and document any set of tools (file, database, codegen, etc.) for LLM agents and automation workflows.
- Easily add and expose any tool (file, database, codegen, etc.) as an MCP tool
- RESTful tool interface for LLM agents and automation
- OpenAPI schema available at
/mcp/openapi.json - Built with Python, FastMCP, Pydantic, and Uvicorn
generic-mcp/
├── mcp_server.py # Main MCP server entrypoint (rename as needed)
├── README.md # This file
├── pyproject.toml # Python project config
└── ...
-
Install dependencies:
uv pip install -r requirements.txt
-
Run the server:
uv run python file_mcp.py --root <workspace-root> # Example: uv run python file_mcp.py --root C:\Users\yourname\ai-play-ground
- The server exposes your custom tools via HTTP at
http://localhost:8123/mcp. - OpenAPI schema: http://localhost:8123/mcp/openapi.json
- Use an MCP-compatible agent or client to call your defined tools.
Define your own tools using the @mcp.tool() decorator in your main server file. Each tool will be automatically exposed via HTTP and documented in the OpenAPI schema.
Example:
@mcp.tool()
def my_tool(param1: str, param2: int) -> dict:
"""Describe what this tool does."""
# ...your logic...
return {"result": ...}See the OpenAPI schema for details on all available tools and their parameters.
- Keep all tool logic in your main server file or organize by feature as needed.
- Use the
@mcp.tool()decorator for every tool you want to expose. - Log important events and errors using the built-in logger.
MIT