crypto_price), inspect the tool, build the MCP server image, deploy the server and a declarative agent, then interact with the agent via the KAgent UI. The steps below follow the same sequence used in the video; examples and commands are included for reproducibility.
1. Stop the running MCP server
Terminate the running MCP server with Ctrl+C in the terminal where it’s running.2. Add a new tool using kmcp
Tools must use snake_case names (for example:crypto_price). Add the tool to your KMCP project with:
3. MCP protocol and tool discovery (overview)
- When an AI agent connects to the MCP server it queries for available tools.
- The MCP server returns metadata for each tool: name, description, parameters, return type, etc.
- Agents rely heavily on the tool’s function docstring (included in the MCP response) to understand usage, parameters and expected return values.
- Use the decorator
@mcp.tool()to register a Python function as an MCP-invokable tool.
4. Example: simple MCP tool implementation
Place this template undersrc/tools/crypto_price.py in the MCP project:
@mcp.tool() and access per-tool configuration through get_tool_config().
5. A robust crypto price tool (CoinGecko)
Below is a fuller example that calls CoinGecko’s simple price API, includes a thorough docstring (agents parse this), basic validation, error handling, and returns a structured dictionary:Provide detailed docstrings: agents parse the docstring to learn the tool’s parameters, behavior and return format. Clear examples and error cases make tool usage more reliable and reduce unexpected behavior from LLM agents.
6. Copy the tool file into the project
If you implemented the tool outside the project tree, copy it into the MCP project tools folder:7. Run the MCP Inspector to validate the tool
Start the MCP Inspector script (example name in this environment:run-mcp-inspector). The Inspector exposes a web UI and prints a proxy address plus a session token; use the token to authenticate in the UI.
Example Inspector output (truncated):
get_crypto_price appears in the Tools list.

8. Run the tool from the Inspector
- Select
get_crypto_price. - Default inputs:
symbol: bitcoin,currency: usd. - Click “Run tool” to invoke the MCP server and retrieve the live price.
9. Package the MCP server into a Docker image
Build the MCP server image using thekmcp build command from your project directory:
--platform flag to control the target CPU architecture (e.g., linux/amd64, linux/arm64) when cross-building.
10. Deploy the MCP server to Kubernetes
Apply the provided Kubernetes manifest for the MCP server (included in the exercise). After applying, verify the MCP server pod is running and that theMCPServer resource reports an accepted/ready state.
11. Deploy the declarative agent that uses the MCP server
Apply the declarative agent manifest (for examplecrypto-price-agent.yaml). The declarative Agent references the MCPServer and lists the tool names the agent can invoke.
Example agent manifest:
12. Interact with the agent via KAgent UI
Open the KAgent UI, selectcrypto-price-agent, and ask natural-language questions such as:
- “What’s the current price of Bitcoin?”
- “What’s the current price of Ethereum in USD?”
- “Compare the price between Bitcoin and Ethereum.”
get_crypto_price, aggregate results and return a Markdown-formatted reply summarizing the results and actions taken. Example: a response listing Bitcoin at ~2,947.37 USD.

Notes and best practices
- Provide clear, example-rich docstrings — agents parse them to determine how to call your tool.
- Validate and normalize inputs (e.g., lowercase
symbol/currency) before calling external APIs. - Add timeouts and robust exception handling for network calls.
- Return structured results (not freeform text) so agents can programmatically use the returned values.
- Allow configurable endpoints and timeouts via
kmcp.yamlso deployments can override defaults.