Skip to main content
If I have seen further, it is by standing on the shoulders of MCP developers.
Turn any Python function into an MCP-compatible tool that works with Claude Desktop, VS Code Copilot, Cursor, and other MCP clients. The benefit of using ahvn Toolkits as MCP servers lies in its persistence and lifecycle management. Once registered, your toolkit can be easily fetched, updated, and transferred across processes and machines without needing to re-define, re-register, or re-import your tool functions. This makes it ideal for building reusable toolkits that can be shared across projects and teams. Also, based on FastMCP and ahvn’s Capsule system, you can convert from any source (e.g., python function, existing MCP, code-string, etc.) to MCP easily, and ahvn handles the rest (e.g., serialization, transport, etc.) for you.

1. Define Your Tools

For example, let’s define two simple tools: one to get the weather for a city, and another to convert Celsius to Fahrenheit.
from ahvn import ToolSpec

def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    # Replace with a real API call
    return f"Weather in {city}: 22°C, sunny"

def convert_temp(celsius: float) -> float:
    """Convert Celsius to Fahrenheit."""
    return celsius * 9 / 5 + 32

2. Build a Toolkit

In ahvn, a Toolkit is a collection of tools that can be served together. They can have shared state, descriptions, metadata, and more. Let’s create a toolkit for our weather tools:
from ahvn.tool import Toolkit

toolkit = Toolkit(
    name="weather_tools",
    description="Weather utilities — lookup and temperature conversion.",
    tools={
        "get_weather": ToolSpec.from_func(get_weather),
        "convert_temp": ToolSpec.from_func(convert_temp),
    },
)
Notice that the description is optional but recommended — it helps the LLMs to understand the purpose of your toolkit and how to use it effectively. It is often worth spending a bit of time crafting clear descriptions for your toolkits and tools to get the best results from LLMs or exporting as skills to use with other ecosystems.

3. Register with TK_AHVN

ahvn has a global TK_AHVN registry for toolkits. This allows you to register your toolkit once and access it from anywhere in your codebase, or even across machines. This is achieved via Capsules and MCP stdio transport, which allows you to store the toolkit definition and tool functions in a database and fetch them on demand without needing to re-import or re-define your tools. For example, let’s register our weather_tools toolkit as a toolkit:
from ahvn import TK_AHVN

TK_AHVN.add(toolkit, overwrite=True)
Now you can get it from anywhere in your codebase:
weather_tools = TK_AHVN.get("weather_tools")
When the TK_AHVN database is migrated to a new machine or shared as a service, your registered toolkits come along with it and are available anywhere. Notice that this tool is registered in the TK_AHVN and is now persistent, even if you remove the original code that defined it. To view all registered toolkits, you can run:
ahvn mcp ls
To remove this toolkit from the registry, you can use:
ahvn mcp rm weather_tools

4. Serve via MCP

After registering your toolkit as weather_tools, you can serve it as an MCP server with a single command:
ahvn mcp serve weather_tools --host 127.0.0.1 --port 7001
This starts an MCP server exposing your toolkit on 127.0.0.1:7001. You can change the host and port as needed for the HTTP transport (default transport is HTTP, and the default host and port are 127.0.0.1 and 7001 respectively). This prints the MCP JSON config (http) for your server, which you can use to connect with any MCP-compatible client:
{
  "mcpServers": {
    "weather_tools": {
      "url": "http://127.0.0.1:7001/weather_tools/mcp",
      "transport": "http"
    }
  }
}
Or you can serve it via stdio transport:
ahvn mcp serve weather_tools --stdio
This prints MCP JSON config as well as a single-line command. MCP JSON (stdio):
{
  "mcpServers": {
    "weather_tools": {
      "command": "<path_to_your_python>/python",
      "args": [
        "<path_to_your_ahvn>/_mcp_stdio.py",
        "weather_tools"
      ]
    }
  }
}
Single-line command (stdio):
<path_to_your_python>/python <path_to_your_ahvn>/_mcp_stdio.py weather_tools

5. Connect a Client

So, we can obtain http MCP config JSON, http MCP config URL, stdio MCP config JSON, or stdio single-line command from the previous step. Generally you can paste the config JSON into the client’s MCP server configuration, but the exact steps depend on the client. Here are instructions for some popular clients:
In Developer > mcp.json, paste the full server MCP JSON in either HTTP or stdio format.

6. Export as a Skill (Optional)

You can export your toolkit as a reusable skill for easy sharing and integration across projects:
ahvn mcp export weather_tools -o ./skills/
# The skill will be exported to ./skills/weather_tools/ with a SKILL.md containing the toolkit definition and usage instructions.
Exported skill:
---
name: weather_tools
description: Weather utilities — lookup and temperature conversion.
tools:
- get_weather
- convert_temp
---
# The `weather_tools` Toolkit
Weather utilities — lookup and temperature conversion.

## Tools (2)

### get_weather
Get the current weather for a city.

**Parameters:**
- `city`: string *(required)*

**Usage:**
```bash
ahvn mcp run weather_tools.get_weather "city=<city>"
```
```python
from ahvn.tool import TK_AHVN
get_weather = TK_AHVN.get('weather_tools').get_tool('get_weather')
print(get_weather(city=<city>))
```

### convert_temp
Convert Celsius to Fahrenheit.

**Parameters:**
- `celsius`: number *(required)*

**Usage:**
```bash
ahvn mcp run weather_tools.convert_temp "celsius=<celsius>"
```
```python
from ahvn.tool import TK_AHVN
convert_temp = TK_AHVN.get('weather_tools').get_tool('convert_temp')
print(convert_temp(celsius=<celsius>))
```

7. Import an Existing MCP (Optional)

If you already have an MCP server running, you can import it as a toolkit without needing to re-define your tools. The imported toolkit is persisted in TK_AHVN — once registered, it survives across processes and machines.

7.1. From a URL

from ahvn.tool import Toolkit, TK_AHVN

toolkit = Toolkit.from_url(
    "http://127.0.0.1:7002/weather_tools/mcp",
    name="weather_tools",
)
TK_AHVN.add(toolkit, overwrite=True)

7.2. From an MCP JSON config

Use the same config format as Claude Desktop, VS Code, etc.:
toolkit = Toolkit.from_mcp_config({
    "mcpServers": {
        "weather_tools": {
            "url": "http://127.0.0.1:7002/weather_tools/mcp",
            "type": "http"
        }
    }
})
TK_AHVN.add(toolkit, overwrite=True)
Either way, the toolkit round-trips cleanly:
print(TK_AHVN.get("weather_tools").to_mcp_config())
# {'mcpServers': {'weather_tools': {'url': 'http://127.0.0.1:7002/weather_tools/mcp', 'transport': 'http'}}}
Any public MCP endpoint works. As a common example, here we import Tavily Search — a web-search MCP with 6 tools:
from ahvn.tool import Toolkit, TK_AHVN

TAVILY_URL = "https://mcp.tavily.com/mcp/?tavilyApiKey=<TAVILY_API_KEY>"

toolkit = Toolkit.from_url(TAVILY_URL, name="tavily")
TK_AHVN.add(toolkit, overwrite=True)
Or register from a config dict:
toolkit = Toolkit.from_mcp_config({
    "mcpServers": {
        "tavily": {
            "url": TAVILY_URL,
            "type": "http",
        }
    }
})
TK_AHVN.add(toolkit, overwrite=True)
Then you can use it in ahvn just like any other toolkit, or export it as a skill for use by agent clients:
ahvn mcp list
#                             Toolkits                            
# ┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┓
# ┃ Name          ┃ Tools                              ┃ Serving ┃
# ┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━┩
# │ tavily        │ tavily_crawl, tavily_extract,      │         │
# │               │ tavily_map, tavily_research,       │         │
# │               │ tavily_search, tavily_skill        │         │
# │ weather_tools │ convert_temp, get_weather          │         │
# └───────────────┴────────────────────────────────────┴─────────┘

ahvn mcp export tavily -o ./skills/
# ✓ Exported 'tavily' to ./skills/tavily

Further Exploration

Quickstart flow:
Toolkit references:
  • Toolkits — toolkit factories, persistence, and lifecycle
  • Tools — ToolSpec and tool construction
  • MCP — transports, clients, and debugging
  • Skills — export a toolkit as a reusable skill