Documentation Index Fetch the complete documentation index at: https://mintlify.com/mcp-use/mcp-use/llms.txt
Use this file to discover all available pages before exploring further.
Quick Start Guide
This guide will help you create your first MCP server with mcp-use in both TypeScript and Python.
TypeScript Quickstart Prerequisites
Node.js 20.19.0 or higher
npm, yarn, or pnpm
Create Your First Server The fastest way to get started is using the project scaffolding tool: npx create-mcp-use-app my-server
cd my-server
npm install
npm run dev
The development server includes hot reload and auto-opens the inspector at http://localhost:3000/inspector
Manual Setup If you prefer to set up manually:
Create Your Server
Create a file server.ts: import { MCPServer , text } from "mcp-use/server" ;
import { z } from "zod" ;
const server = new MCPServer ({
name: "my-server" ,
version: "1.0.0" ,
});
server . tool ({
name: "get_weather" ,
description: "Get weather for a city" ,
schema: z . object ({ city: z . string () }),
}, async ({ city }) => {
return text ( `Temperature: 72°F, Condition: sunny, City: ${ city } ` );
});
await server . listen ( 3000 );
// Inspector at http://localhost:3000/inspector
Run Your Server
Your server is now running!
MCP endpoint: http://localhost:3000/mcp
Inspector UI: http://localhost:3000/inspector
Test Your Server Open the inspector at http://localhost:3000/inspector and try calling your tool: {
"city" : "San Francisco"
}
The inspector provides a web interface to test all your tools, resources, and prompts without writing any client code.
Add More Features // Add a resource that provides static data
server . resource ({
name: "config" ,
uri: "app://config" ,
title: "Application Config" ,
}, async () => {
return text ( JSON . stringify ({
version: "1.0.0" ,
features: [ "weather" , "search" ]
}));
});
Python Quickstart Prerequisites
Python 3.11 or higher
pip
Installation
Install LLM Provider
Choose your preferred LLM provider: # For OpenAI
pip install langchain-openai
# For Anthropic
pip install langchain-anthropic
Set API Keys
Create a .env file: OPENAI_API_KEY = your_api_key
# or
ANTHROPIC_API_KEY = your_api_key
Create an MCP Server from typing import Annotated
from mcp.types import ToolAnnotations
from pydantic import Field
from mcp_use import MCPServer
server = MCPServer( name = "Weather Server" , version = "1.0.0" )
@server.tool (
name = "get_weather" ,
description = "Get current weather information for a location" ,
annotations = ToolAnnotations( readOnlyHint = True , openWorldHint = True ),
)
async def get_weather (
city : Annotated[ str , Field( description = "City name" )],
) -> str :
return f "Temperature: 72°F, Condition: sunny, City: { city } "
# Start server with auto-inspector
server.run( transport = "streamable-http" , port = 8000 )
# Inspector at http://localhost:8000/inspector
Build an MCP Agent Create an AI agent that connects to MCP servers: import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from mcp_use import MCPAgent, MCPClient
async def main ():
load_dotenv()
# Configure MCP servers
config = {
"mcpServers" : {
"playwright" : {
"command" : "npx" ,
"args" : [ "@playwright/mcp@latest" ],
}
}
}
# Create client and agent
client = MCPClient.from_dict(config)
llm = ChatOpenAI( model = "gpt-4o" )
agent = MCPAgent( llm = llm, client = client, max_steps = 30 )
# Run a query
result = await agent.run(
"Find the best restaurant in San Francisco using Google Search"
)
print ( f "Result: { result } " )
if __name__ == "__main__" :
asyncio.run(main())
Streaming Agent Output Get real-time feedback from your agent: async for chunk in agent.stream( "Find restaurants in Tokyo" ):
print (chunk[ "messages" ], end = "" , flush = True )
Streaming is ideal for building responsive UIs that show agent progress in real-time.
Multi-Server Support Connect to multiple MCP servers simultaneously: config = {
"mcpServers" : {
"airbnb" : {
"command" : "npx" ,
"args" : [ "-y" , "@openbnb/mcp-server-airbnb" ]
},
"playwright" : {
"command" : "npx" ,
"args" : [ "@playwright/mcp@latest" ]
}
}
}
client = MCPClient.from_dict(config)
agent = MCPAgent(
llm = llm,
client = client,
use_server_manager = True # Enable smart server selection
)
result = await agent.run(
"Search for a place in Barcelona on Airbnb, "
"then find nearby restaurants using Google"
)
Next Steps
Build Your First Server Learn to build a complete MCP server with tools, resources, and prompts
Create MCP Apps Build interactive widgets for ChatGPT and Claude
Connect to Servers Learn different ways to connect to MCP servers
Build AI Agents Create intelligent agents that use MCP tools
Common Issues
If port 3000 (TypeScript) or 8000 (Python) is already in use, specify a different port: await server . listen ( 3001 );
server.run( transport = "streamable-http" , port = 8001 )
Make sure you’ve installed all dependencies: TypeScript: Python: pip install mcp-use langchain-openai
TypeScript execution errors
Use tsx to run TypeScript files directly: Or compile first: npm run build
node dist/server.js