This SDK builds on top of the original SDK. Please refer to the original repository's README for general information. This README focuses on North-specific details.
This repository provides code to enable your server to use authentication with North, a custom extension to the original specification. Other than that, no changes are made to the SDK; this builds on top of it.
Main differences
North only supports the StreamableHTTP transport. The sse transport is deprecated, it will work for backwards compatibility, but you shouldn't use it if you are creating new servers
You can validate North user identity with ID tokens and optionally restrict
accepted identity providers with trusted_issuers for production.
You can access the user's OAuth token to interact with third-party services on their behalf.
You can access the user's identity (from the identity provider used with North).
Debug mode for detailed authentication logging and troubleshooting.
OpenTelemetry helpers for custom spans, log/trace correlation, and privacy-aware error recording (built on FastMCP telemetry).
Built-in health check endpoint for Kubernetes liveness probes (enabled by default).
Health Check
NorthMCPServer includes a built-in /health endpoint that responds to GET requests with a 200 OK plain-text response. This is useful for Kubernetes liveness/readiness probes and load balancer health checks. The endpoint bypasses authentication, so no tokens are needed.
This repository contains example servers that you can use as a quickstart. You can find them in the examples directory.
Examples cover authentication, tool metadata for the North UI, debug mode, and OpenTelemetry (examples/telemetry-demo/).
Authentication
This SDK offers several strategies for authenticating users and authorizing their requests.
I only want North to be able to send requests to my server
North sends an X-North-ID-Token with requests. For production, configure
trusted_issuers so your server verifies that token was issued by an expected
identity provider. For local development or lower-risk setups, this setting is
optional and tokens are decoded without signature verification.
I want to get the identity of the north user that is calling my server
Refer to examples/server_with_auth.py. During your request call the following:
user = get_authenticated_user()
print(user.email)
I need access to a third party service via oauth (e.g.: google drive, slack, etc...)
Similar as above:
user = get_authenticated_user()
print(user.connector_access_tokens)
Debug Mode
The North MCP SDK includes a comprehensive debug mode that provides detailed logging of authentication processes, incoming requests, and token validation. This is invaluable when troubleshooting authentication issues.
See examples/server_with_debug.py for a runnable example.
Security Note
Debug mode logs sensitive information including request headers and token metadata. Never enable debug mode in production environments as it may expose authentication details in logs.
OpenTelemetry
FastMCP 3 emits a span for each tool call when a TracerProvider is configured. The North SDK adds helpers on top of that; it does not install exporters or configure where traces are sent — opentelemetry-sdk and OTLP exporters are not bundled dependencies. Servers run fine without a TracerProvider; traces become no-ops until you add one.
What the SDK provides
Helper
Purpose
TelemetryConfig
Opt-in config object for the telemetry integration (sensitive-data policy, log/trace correlation)
mcp.telemetry.traced_span
Custom spans nested under FastMCP tool spans, driven by the server's TelemetryConfig. Use this when you have mcp in scope.
traced_span (module-level)
Same context manager, but auto-resolves the active server's config via fastmcp.server.dependencies.get_server. Use this from tool bodies that don't hold an mcp reference.
get_telemetry_config()
Returns the active NorthMCPServer's TelemetryConfig (or a private "off" config when there's no active North server). Lets tools branch on record_sensitive_data without an mcp reference.
Depends
Re-export of FastMCP's Depends factory. Combine with get_telemetry_config for FastAPI-style parameter injection: telemetry: TelemetryConfig = Depends(get_telemetry_config).
get_tracer
Re-export of FastMCP's tracer (fastmcp instrumentation name)
TraceContextFormatter
Appends trace_id / span_id to log lines on the NorthMCP.{name} logger when a span is active
Setup
Register a TracerProvider and exporters in main before importing NorthMCPServer (FastMCP reads the global provider at import time). Use your own setup or standard OTel env vars (OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_SERVICE_NAME, etc.).
Pass a TelemetryConfig to NorthMCPServer — this is the opt-in signal. When log_trace_context is enabled (the default for an opted-in config), trace/span IDs are appended automatically to NorthMCP.* log lines.
Inject the config into tools with Depends(get_telemetry_config) and call telemetry.traced_span(...) for custom spans. See the helper table for mcp.telemetry and bare-import alternatives.
def configure_tracing() -> None:
# Install opentelemetry-sdk + exporters in your server project.
# See examples/telemetry-demo/main.py for a minimal OTLP gRPC example.
...
def main() -> None:
configure_tracing()
from north_mcp_python_sdk import (
Depends,
NorthMCPServer,
TelemetryConfig,
get_telemetry_config,
)
mcp = NorthMCPServer(
"Search",
telemetry=TelemetryConfig(
record_sensitive_data=False,
log_trace_context=True,
),
)
@mcp.tool()
async def search(
query: str,
telemetry: TelemetryConfig = Depends(get_telemetry_config),
) -> list[dict]:
# FastMCP injects the active server's TelemetryConfig as `telemetry`
# before the tool body runs. No reference to `mcp` is needed, and
# `telemetry.traced_span` honours `record_sensitive_data` for
# exception details.
with telemetry.traced_span(
"search.provider_call",
attributes={"search.query_length": len(query)},
) as span:
if telemetry.record_sensitive_data:
span.add_event("search.query", {"query": query})
results = await provider.search(query)
span.set_attribute("search.result_count", len(results))
return results
Depends(...) in a default trips ruff's B008 and basedpyright's reportCallInDefaultInitializer. Whitelist Depends as configured in this repo's pyproject.toml; this is the same approach FastAPI projects use.
When True, traced_span records full exception messages on spans and tools may attach sensitive payloads (query text, IDs, etc.) as span events. Off by default for safety; opt in explicitly in code only.
log_trace_context
True
When True, the SDK attaches a formatter that appends trace_id / span_id to log lines on the NorthMCP.* logger while a span is active.
If you leave telemetry=None, the SDK uses an internal "telemetry not opted in" config: both flags False, no formatter is attached to the NorthMCP.* logger, and traced_span records only the exception type name on error. Neither flag has an environment-variable fallback. FastMCP's own tool/resource/prompt spans are unaffected — they still appear whenever a TracerProvider is configured.
This guide describes how to test your MCP server locally without connecting it to North. For this, we will use the MCP Inspector. You can run it with:
npx @modelcontextprotocol/inspector
If authentication is not required and you just want to run it locally, you can choose the stdio transport. Navigate to the MCP Inspector and configure it as follows:
Transport Type: stdio
Command: uv
Arguments: run examples/server_with_auth.py --transport stdio
From here:
Click "Connect"
Select "Tools" on the top of the screen.
Click "List Tools" -> "add"
Add the numbers and click "Run". You should see the sum.
Adding authentication
If you want to test the authentication mechanism locally you can do the following. First start the server with the streamable http transport:
uv run examples/server_with_auth.py --transport streamable-http
Next, create a bearer token. You can generate one using examples/create_bearer_token.py or use a pre-made one.
Navigate to the MCP Inspector and configure it like this:
Chưa có danh sách công cụ. Máy chủ từ xa sẽ có danh sách sau lần kiểm tra tình trạng đầu tiên.
Câu hỏi thường gặp
Câu hỏi
Làm thế nào để cài đặt North MCP Python Sdk?
Sao chép cấu hình stdio cho Cursor, Claude Desktop, Claude Code hoặc VS Code trên trang này. Cấu hình dùng bản cài đặt của nhà phát hành, không phải proxy của PlugMCP.
North MCP Python Sdk có cần khóa API không?
Bản ghi này không liệt kê biến môi trường bắt buộc nào.
North MCP Python Sdk dùng giao thức truyền tải nào?
North MCP Python Sdk chạy cục bộ qua stdio.
North MCP Python Sdk được kiểm tra lần cuối khi nào?
Kiểm tra lần cuối: 2026-11-05. An sdk for creating MCP Servers with north