CarbonArc MCP客户端示例

提供一套使用官方 MCP SDK 编写的多语言客户端示例,用于连接 CarbonArc MCP 服务器、通过 OAuth 2.0 认证并调用工具发现与实体搜索功能。

  • by Carbon-Arc
  • Go
  • 混合部署
  • 更新于
在 GitHub 查看 Carbon-Arc/carbonarc-mcp-clients

使用说明

CarbonArc MCP Client Examples

Minimal, self-contained MCP client examples showing how to connect to the CarbonArc MCP server from every popular language using the official Model Context Protocol SDKs.

Each example follows the same pattern:

  1. Connect to https://mcp.carbonarc.ai/ over Streamable HTTP
  2. Authenticate via OAuth 2.0 (browser opens automatically where supported)
  3. Discover available tools
  4. Call search_entities with "Walmart" as a quick smoke test

Client Examples at a Glance

Language Directory SDK Transport
Python python/ fastmcp Streamable HTTP
TypeScript / Node.js typescript/ @modelcontextprotocol/sdk StreamableHTTPClientTransport
Go go/ modelcontextprotocol/go-sdk StreamableClientTransport

Python

cd python
uv run python mcp_example.py

TypeScript / Node.js

Uses the official MCP TypeScript SDK (@modelcontextprotocol/sdk). Includes a full OAuth 2.0 authorization-code flow with a local callback server.

cd typescript
npm install
npx tsx mcp-example.ts

Go

Uses the official MCP Go SDK (v1.5.0+). Requires Go 1.25+.

cd go
go mod tidy
go run -tags mcp_go_client_oauth .

Authentication

The CarbonArc MCP server requires OAuth 2.0 authentication. Most examples handle this by:

  1. Discovering the authorization endpoint via the server's /.well-known/oauth-protected-resource metadata.
  2. Registering a client dynamically (RFC 7591) if needed.
  3. Opening a browser for the user to log in.
  4. Receiving the auth code on a local callback server.
  5. Exchanging the code for an access token.

All three client examples implement the full browser-based OAuth flow.

Security

These examples are minimal quickstarts designed to demonstrate MCP connectivity. They store OAuth tokens in memory for the duration of the script and do not include:

  • Token encryption at rest
  • Audit logging
  • Rate limiting
  • Secret scanning or rotation

For production-grade security patterns — including AES-256-GCM token encryption, SOC 2 controls mapping, and reference implementations for AWS Secrets Manager, GCP Secret Manager, Azure Key Vault, and HashiCorp Vault — see the Carbon Arc Partnership Examples repository, specifically embedded-ca-user/SECURITY.md.

Further Reading