
- An agent requests a tool (for example, “get Bitcoin price”).
- The agent calls the MCP server’s tool endpoints.
- The MCP server executes the tool code (fetches live price), processes the response, and returns it.
- KMCP helps scaffold the project, run locally with the Inspector, build a container image, and deploy the MCP server to Kubernetes.
KMCP is the CLI for building and managing Model Context Protocol (MCP) servers. Do not confuse it with the KAgent CLI — KAgent CLI focuses on building and interacting with agents, while KMCP focuses on MCP server tooling, scaffolding, local debugging, builds, and deployments.
Install KMCP CLI and MCP Inspector
Install the MCP Inspector (GUI for testing/debugging) and the kmcp CLI.Initialize a Python MCP Project
Create a new Python MCP scaffold:Project Key Files
Below is a quick reference to the key files generated bykmcp init:
Example
kmcp.yaml (abbreviated):
Do not commit sensitive keys or API secrets to version control. Use
kmcp secrets with a secrets provider (env files or Kubernetes Secrets) and reference them from kmcp.yaml so your tools can read them securely at runtime.Inspecting src/main.py
The generatedsrc/main.py boots the FastMCP server and registers tools. It typically parses CLI arguments for transport and host/port, then starts the server.
Representative excerpt:
DynamicMCPServerloads tools fromsrc/toolsand exposes them over the chosen transport.- Use
--transport httpfor running as an HTTP service (suitable for Kubernetes), orstdiofor Inspector/local development.
Tools: Example echo tool
Tools live undersrc/tools. Each tool is a Python function decorated with @mcp.tool() so the MCP server can register it and expose metadata.
Example src/tools/echo.py:
@mcp.tool()registers the function as a callable MCP tool.- Type annotations help schema generation for inputs/outputs.
- Docstrings are surfaced in the Inspector UI as descriptions.
- Use
core.utils.get_tool_configto read tool-specific configuration fromkmcp.yaml.
Add a New Tool and Run Locally
Add a new tool scaffold to your project:MCP Inspector — Visual Debugging and Testing
MCP Inspector is a Postman-like UI for exploring and invoking tools exposed by an MCP server. It proxies connections to the running server and displays tools, schemas, and responses. Example inspector startup output:Connecting the Inspector to the MCP Server
In the Inspector UI, configure the connection:- Transport Type: STDIO
- Command:
uv(the uv entrypoint used in the generated project) - Arguments:
run python /root/crypto-price-mcp/src/main.py
Listing and Running Tools in Inspector
The Inspector lists available tools and their input/output schemas. For the scaffolded project you’ll see theecho tool.
Inspector tools listing example:
echo tool by providing input and clicking Run. Example response shown by Inspector:
Build and Deploy (Overview)
Once your tools are ready, build a Docker image and deploy to Kubernetes:kmcp --help for command options for init, add-tool, run, build, deploy, install, and secrets management.
Next Steps / Recommendations
- Implement a real crypto pricing tool under
src/tools/that calls a public API for BTC/ETH prices. - Store API keys and secrets via
kmcp.yamland a secrets provider; fetch them in tools withcore.utils.get_tool_config. - Iterate rapidly using MCP Inspector during development to validate tool schemas and responses.
- When satisfied, run
kmcp buildto produce an image andkmcp deployto push to Kubernetes. - Read the KMCP repository and docs for advanced deployment options and controllers.