Skip to main content

Connect

The SDK creates the authenticated MCP connection. Your MCP client or agent framework drives the protocol.

Create a connection​

from cortexhub import Cortexhub

cx = Cortexhub()

connection = cx.mcp(
agent="your-registered-agent-reference",
end_user_subject="user-193",
)

url = connection.url
headers = connection.headers

For a conversation, prefer a session so model and tool activity share the same grouping:

session = cx.session(
agent="your-registered-agent-reference",
mcp_session_id="conversation-8472",
end_user_subject="user-193",
)
connection = session.mcp

The API-key path requires end_user_subject. Use the same subject for every turn made on behalf of that user.

Official MCP client​

pip install "cortexhub[mcp]"
import asyncio

from cortexhub import Cortexhub
from mcp import ClientSession

async def main() -> None:
cx = Cortexhub()
session = cx.session(
agent="your-registered-agent-reference",
mcp_session_id="conversation-8472",
end_user_subject="user-193",
)

async with session.mcp.open() as (read, write):
async with ClientSession(read, write) as mcp:
await mcp.initialize()
result = await mcp.list_tools()
print([tool.name for tool in result.tools])

asyncio.run(main())

If your framework has its own Streamable HTTP MCP transport, pass connection.url and connection.headers directly.

MCP protocol​

Standard protocol methods include initialize, tools/list, tools/call, and ping. Use cortexhub_search_tools, cortexhub_get_tool_schemas, and cortexhub_invoke_tools to discover and call downstream toolkit tools. Do not call provider tool names directly.

See also​