Ir para o conteúdo

Quickstart

A native MCP server, no API keys, runs offline. Install and:

Python
import asyncio
from apogee_ai_comunication import (
    ClientConfig, NativeMcpClient, NativeMcpServer,
    ServerConfig, ToolDefinition, ToolInvocation,
)


async def main() -> None:
    server = NativeMcpServer(ServerConfig())

    @server.tool(
        ToolDefinition(
            name="add",
            description="Sum a + b",
            input_schema={"type": "object", "properties": {
                "a": {"type": "integer"}, "b": {"type": "integer"}
            }, "required": ["a", "b"]},
        )
    )
    async def _add(a: int, b: int) -> int:
        return a + b

    client = NativeMcpClient(ClientConfig(base_url="m://"), dispatcher=server.dispatch)
    print(await client.list_tools())
    res = await client.call_tool(ToolInvocation(name="add", arguments={"a": 2, "b": 3}))
    print("answer:", res.content)


asyncio.run(main())

For the other protocols, see the examples/ folder in the module repository or the Protocols section.