home / mcp / mcp calculator mcp server
Xiaozhi MCP sample program
Configuration
View docs{
"mcpServers": {
"78-mcp-calculator": {
"command": "python",
"args": [
"mcp_pipe.py",
"calculator.py"
],
"env": {
"MCP_ENDPOINT": "https://mcp.example.com/mcp"
}
}
}
}You can extend AI capabilities by exposing tools through MCP so language models can invoke them to perform computations, interact with external systems, or access knowledge sources. This server-based approach lets you run local tools and connect them to AI workflows with secure, real-time communication.
You run a local MCP server tool and connect your AI client to it. Start by launching the local stdio server that hosts a calculator tool, then use your MCP client to request mathematical operations or invoke the tool’s APIs as part of your AI workflow. The server handles tool invocation, data flow, and results back to the AI system, enabling dynamic calculations and extended capabilities without leaving your model’s context.
Prerequisites you need before setup are Python 3.7 or newer and a working Python environment.
Install project dependencies with pip.
Set up your MCP endpoint if you have a remote configuration.
Run the calculator example to start the local MCP tool server.
Run all configured servers if you want to start every available MCP tool in this setup.
Configuration relies on a configuration file named mcp_config.json to describe servers and transports (supports stdio and HTTP proxies). You can also set the MCP_ENDPOINT environment variable to point to your MCP server endpoint if you are using a remote setup.
A concrete example of starting a single local server and a full pipe is shown here. The stdio startup uses a Python command to run the pipe which hosts the calculator tool.
pip install -r requirements.txt
export MCP_ENDPOINT=<your_mcp_endpoint>
# Start the calculator server locally
python mcp_pipe.py calculator.py
# Or start all configured servers
python mcp_pipe.pyTool description here