Skip to main content

cogno-mcp

Bridge an MCP server's tools to the Cogno tool contract.

The third tool source for the Cogno stack — alongside in-process skills (cogno-cortex) and the host's native functions. MCPDispatcher exposes any MCP server's tools as a cogno-anima ToolDispatcher, so the EGO / cogno-soma see MCP tools as ordinary tools and never speak the protocol.

The valuable part — schema conversion, CallToolResult → ToolResult mapping, and policy (read-only / destructive) from MCP tool annotations — is SDK-free and fully tested with fakes. The thin transport helpers (stdio / HTTP / SSE) are the only place the official mcp SDK is used; transport is the SDK's job, not ours.

MCP server ──(stdio/HTTP/SSE)──▶ MCPDispatcher ──▶ ToolDispatcher ──▶ EGO / cogno-soma
                                  (implements cogno-anima's contract)

Install

pip install "cogno-mcp[mcp]"     # [mcp] pulls the official MCP SDK (for transport)

cogno-anima (the contract) is a runtime dep not yet on PyPI — install it from git first; see .github/workflows/ci.yml. Without the [mcp] extra the MCPDispatcher still works against any session you provide; the transport helpers raise a clear MCPUnavailableError.

Use

import sys
from cogno_mcp import MCPDispatcher, stdio_session

async with stdio_session(sys.executable, args=["my_server.py"]) as session:
    dispatcher = await MCPDispatcher.create(session)          # lists + caches tools

    dispatcher.tools_schema()            # OpenAI tool defs the EGO offers
    dispatcher.is_mutating("wipe")       # from the tool's readOnlyHint
    dispatcher.requires_confirmation("wipe")   # from its destructiveHint

    await pipe.run_turn(ctx, cfg, dispatcher=dispatcher)      # cogno-soma

Transports: stdio_session(command, args=...) (subprocess), http_session(url) (Streamable HTTP), sse_session(url) (legacy SSE). Each is an async context manager that connects, initialize()s, and tears down on exit — the host owns the lifecycle.

Mapping

MCP → cogno-anima
Tool.name/description/inputSchema tools_schema() OpenAI function def
CallToolResult.content (text blocks) ToolResult.output
CallToolResult.isError = True recoverable ToolResult(ok=False)
transport / protocol exception raises MCPDispatchError (EGO propagates)
unknown tool name recoverable ToolResult(ok=False)
annotations.readOnlyHint is_mutating (absent/false → conservative true)
annotations.destructiveHint = True requires_confirmation (drives the EGO gate)

Skills + MCP + native together

Each source is a ToolDispatcher; merge them per persona:

from cogno_anima.tools import CompositeDispatcher
dispatcher = CompositeDispatcher([cortex_dispatcher, mcp_dispatcher, native_dispatcher])

The ToolDispatcher contract is the unifier — skill / MCP / native are just sources.

The Cogno ecosystem

cogno-mcp is one organ of Cogno — a family of small, composable, Apache-2.0 libraries that together form a complete conversational-agent platform. Each library owns a single concern and stays infra-agnostic; a host assembles them into a running agent:

The Cogno ecosystem

The open-source libraries are the organs; the host is the body that joins them. Our reference host — cogno-host, with its cogno-ui dashboard — is the private product layer, but it holds no special powers: everything it does rides on the public seams documented in each library's docs/HOST_INTEGRATION.md, so you can assemble a body of your own.

Development

pip install -e ".[dev]"
pytest tests/unit -q            # SDK-free dispatcher logic against fakes
pytest tests/integration -q     # MCPDispatcher vs a real FastMCP server over stdio
ruff check cogno_mcp tests && mypy cogno_mcp
python examples/host_min.py     # spawns a local MCP server and calls a tool

Apache-2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cogno_mcp-0.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cogno_mcp-0.1.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file cogno_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: cogno_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for cogno_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 720610e57854f358fc2053800ca440237003d75632726125fd30c365b22998b9
MD5 44d809587563f28bca40fd29592f9a65
BLAKE2b-256 f17efaa64db22130f3ad7498916b5a536ab48c0f78c3e3be23f36faecf77a98e

See more details on using hashes here.

File details

Details for the file cogno_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cogno_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for cogno_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1bc49afa91bb05d023e2026e030455611b81dd45848f3d52c392afaeb5799d98
MD5 307f19e3cd5c1444b30cc9ff34ad0cb4
BLAKE2b-256 13fb8e3e75c25adef1f551f671446db2f62c2a7021541cb31c43b60d616b1e54

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page