SDKs
Examples
Runnable code examples for TypeScript and Python SDKs
Examples
Complete, runnable examples demonstrating common use cases for both SDKs.
Repository
All examples are available on GitHub:
github.com/aistack/routermcp-sdks/tree/main/examples
TypeScript Examples
| Example | Description |
|---|---|
| 01-basic-connection | Connect, list tools, call a tool |
| 02-typed-results | Type-safe results with Zod schemas |
| 03-error-handling | Handle all error types gracefully |
| 04-multi-user-sessions | Isolated sessions per user |
| 05-oauth-flow | OAuth adapters and authorization |
| 06-vercel-ai | Vercel AI SDK integration |
| 07-langchain | LangChain agent with MCP tools |
| 08-google-adk | Google ADK function calling |
| 09-mastra | Mastra agent integration |
Quick Start
cd examples/typescript
cp .env.example .env
npm install
npm run example:01Python Examples
| Example | Description |
|---|---|
| 01_basic_connection | Async client with context manager |
| 02_typed_results | Pydantic model validation |
| 03_error_handling | Comprehensive error handling |
| 04_multi_user_sessions | RouterMCPSession for multiple users |
| 05_oauth_flow | OAuth adapter configuration |
| 06_sync_client | Synchronous client for scripts |
| 07_langchain | LangChain agent integration |
| 08_google_adk | Google ADK tools |
Quick Start
cd examples/python
cp .env.example .env
pip install -r requirements.txt
python examples/01_basic_connection.pyEnvironment Variables
Both example sets use the same environment variables:
| Variable | Required | Description |
|---|---|---|
ROUTERMCP_API_KEY | Yes | Your RouterMCP API key |
ROUTERMCP_USER_ID | No | User ID for OAuth token storage |
OPENAI_API_KEY | For AI examples | OpenAI API key |
GOOGLE_API_KEY | For ADK examples | Google API key |
The SDK defaults to https://routermcp.com as the base URL.
Framework Dependencies
Framework integrations require additional dependencies:
TypeScript
npm install ai @ai-sdk/openai # Vercel AI SDK
npm install langchain @langchain/openai # LangChain
npm install @google/generative-ai # Google ADK
npm install @mastra/core # MastraPython
pip install langchain langchain-openai # LangChain
pip install google-generativeai # Google ADK