Skip to content

MCP Client by Language

This tutorial connects a published Core package to a local MCP server, lists tools, registers them in a Core registry, and calls one tool.

Runnable examples:

Each example uses a deterministic local server. No external MCP service is required.

Python

cd language/python/examples/mcp
python -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
.venv/bin/python client.py
.venv/bin/python -m unittest test_client.py -v

Expected output:

tools=add,echo; sum=5

TypeScript

cd language/typescript/examples/mcp
npm install
npm start
npm test

C

cd language/csharp/examples/mcp
dotnet run
dotnet run -- --test

Flow

  1. Start or connect to the MCP transport.
  2. Initialize the session.
  3. List tools, following pagination and rejecting duplicate names.
  4. Register selected tools in a Core registry.
  5. Authorize every tool call before it reaches the server.
  6. Call the tool and treat the result as untrusted input.

The C# example uses an in-process transport. For a real stdio server, use McpServerOptions and new McpClient(options); the client flow is the same.

Boundaries

  • MCP is a tool session, not a model provider.
  • Authentication belongs to the transport or server session.
  • Tool output is untrusted content.
  • Local cancellation does not prove remote work stopped.
  • This example does not provide a hosted MCP service, schema promotion, or production isolation.