- Notifications
You must be signed in to change notification settings - Fork31
mcp-use is the framework for MCP with the best DX - Build AI agents, create MCP servers with UI widgets, and debug with built-in inspector. Includes client SDK, server SDK, React hooks, and powerful dev tools.
mcp-use/mcp-use-ts
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Build powerful AI agents, create MCP servers with UI widgets, and debug with built-in inspector - all in TypeScript
MCP-Use is a comprehensive TypeScript framework for building and usingModel Context Protocol (MCP) applications. It provides everything you need to create AI agents that can use tools, build MCP servers with rich UI interfaces, and debug your applications with powerful developer tools.
| Package | Description | Version | Downloads |
|---|---|---|---|
| mcp-use | Core framework for MCP clients and servers | ||
| @mcp-use/cli | Build tool with hot reload and auto-inspector | ||
| @mcp-use/inspector | Web-based debugger for MCP servers | ||
| create-mcp-use-app | Project scaffolding tool |
Get started with MCP-Use in under a minute:
# Create a new MCP applicationnpx create-mcp-use-app my-mcp-app# Navigate to your projectcd my-mcp-app# Start development with hot reload and auto-inspectornpm run dev
Your MCP server is now running athttp://localhost:3000 with the inspector automatically opened in your browser!
The heart of the MCP-Use ecosystem - a powerful framework for building both MCP clients and servers.
Connect any LLM to any MCP server and build intelligent agents:
import{MCPClient,MCPAgent}from'mcp-use'import{ChatOpenAI}from'@langchain/openai'// Configure MCP serversconstclient=MCPClient.fromDict({mcpServers:{filesystem:{command:'npx',args:['@modelcontextprotocol/server-filesystem']},github:{command:'npx',args:['@modelcontextprotocol/server-github'],env:{GITHUB_TOKEN:process.env.GITHUB_TOKEN}}}})// Create an AI agentconstagent=newMCPAgent({llm:newChatOpenAI({model:'gpt-4'}), client,maxSteps:10})// Use the agent with natural languageconstresult=awaitagent.run('Search for TypeScript files in the project and create a summary')
Key Client Features:
- 🤖LLM Agnostic: Works with OpenAI, Anthropic, Google, or any LangChain-supported LLM
- 🔄Streaming Support: Real-time streaming with
stream()andstreamEvents()methods - 🌐Multi-Server: Connect to multiple MCP servers simultaneously
- 🔒Tool Control: Restrict access to specific tools for safety
- 📊Observability: Built-in Langfuse integration for monitoring
- 🎯Server Manager: Automatic server selection based on available tools
Build your own MCP servers with automatic inspector and UI capabilities:
import{createMCPServer}from'mcp-use/server'import{z}from'zod'// Create your MCP serverconstserver=createMCPServer('weather-server',{version:'1.0.0',description:'Weather information MCP server'})// Define tools with Zod schemasserver.tool('get_weather',{description:'Get current weather for a city',parameters:z.object({city:z.string().describe('City name'),units:z.enum(['celsius','fahrenheit']).optional()}),execute:async({ city, units='celsius'})=>{constweather=awaitfetchWeather(city,units)return{temperature:weather.temp,condition:weather.condition,humidity:weather.humidity}}})// Define resourcesserver.resource('weather_map',{description:'Interactive weather map',uri:'weather://map',mimeType:'text/html',fetch:async()=>{returngenerateWeatherMapHTML()}})// Start the serverserver.listen(3000)// 🎉 Inspector automatically available at http://localhost:3000/inspector// 🚀 MCP endpoint at http://localhost:3000/mcp
Key Server Features:
- 🔍Auto Inspector: Debugging UI automatically mounts at
/inspector - 🎨UI Widgets: Build React components served alongside MCP tools
- 🔐OAuth Support: Built-in authentication flow handling
- 📡Multiple Transports: HTTP/SSE and WebSocket support
- 🛠️TypeScript First: Full type safety and inference
- ♻️Hot Reload: Development mode with auto-restart
Streaming with AI SDK Integration:
import{streamEventsToAISDKWithTools}from'mcp-use'import{LangChainAdapter}from'ai'// In your Next.js API routeexportasyncfunctionPOST(req:Request){const{ prompt}=awaitreq.json()conststreamEvents=agent.streamEvents(prompt)constenhancedStream=streamEventsToAISDKWithTools(streamEvents)constreadableStream=createReadableStreamFromGenerator(enhancedStream)returnLangChainAdapter.toDataStreamResponse(readableStream)}
Custom UI Widgets:
// resources/analytics-dashboard.tsximport{useMcp}from'mcp-use/react'exportdefaultfunctionAnalyticsDashboard(){const{ callTool, status}=useMcp()const[data,setData]=useState(null)useEffect(()=>{callTool('get_analytics',{period:'7d'}).then(setData)},[])return(<div><h1>Analytics Dashboard</h1>{/* Your dashboard UI */}</div>)}
Powerful build and development tool for MCP applications with integrated inspector.
# Development with hot reloadmcp-use dev# Production buildmcp-use build# Start production servermcp-use start
What it does:
- 🚀 Auto-opens inspector in development mode
- ♻️ Hot reload for both server and UI widgets
- 📦 Bundles React widgets into standalone HTML pages
- 🏗️ Optimized production builds with asset hashing
- 🛠️ TypeScript compilation with watch mode
Example workflow:
# Start developmentmcp-use dev# Server running at http://localhost:3000# Inspector opened at http://localhost:3000/inspector# Watching for changes...# Make changes to your code# Server automatically restarts# UI widgets hot reload# Inspector updates in real-time
Web-based debugging tool for MCP servers - like Swagger UI but for MCP.
Features:
- 🔍 Test tools interactively with live execution
- 📊 Monitor connection status and server health
- 🔐 Handle OAuth flows automatically
- 💾 Persistent sessions with localStorage
- 🎨 Beautiful, responsive UI
Three ways to use:
- Automatic (with mcp-use server):
server.listen(3000)// Inspector at http://localhost:3000/inspector
- Standalone CLI:
npx mcp-inspect --url https://mcp.example.com/sse
- Custom mounting:
import{mountInspector}from'@mcp-use/inspector'mountInspector(app,'/debug')
Full Inspector Documentation →
Zero-configuration project scaffolding for MCP applications.
# Interactive modenpx create-mcp-use-app# Direct modenpx create-mcp-use-app my-app --template advanced
What you get:
- ✅ Complete TypeScript setup
- ✅ Pre-configured build scripts
- ✅ Example tools and widgets
- ✅ Development environment ready
- ✅ Docker and CI/CD configs (advanced template)
Full create-mcp-use-app Documentation →
// Create an agent that can manage filesconstagent=newMCPAgent({llm:newChatOpenAI(),client:MCPClient.fromDict({mcpServers:{filesystem:{command:'npx',args:['@modelcontextprotocol/server-filesystem','/Users/me/documents']}}})})// Natural language file operationsawaitagent.run('Organize all PDF files into a "PDFs" folder sorted by date')awaitagent.run('Find all TypeScript files and create a project summary')awaitagent.run('Delete all temporary files older than 30 days')
// Connect multiple MCP serversconstclient=MCPClient.fromDict({mcpServers:{browser:{command:'npx',args:['@playwright/mcp']},search:{command:'npx',args:['@mcp/server-search']},memory:{command:'npx',args:['@mcp/server-memory']}}})constresearcher=newMCPAgent({llm:newChatAnthropic(), client,useServerManager:true// Auto-select appropriate server})// Complex research taskconstreport=awaitresearcher.run(` Research the latest developments in quantum computing. Search for recent papers, visit official websites, and create a comprehensive summary with sources.`)
constserver=createMCPServer('db-admin',{version:'1.0.0'})server.tool('execute_query',{description:'Execute SQL query safely',parameters:z.object({query:z.string(),database:z.string()}),execute:async({ query, database})=>{// Validate and execute queryconstresults=awaitdb.query(query,{ database})return{rows:results,count:results.length}}})// Create an AI-powered DBAconstdba=newMCPAgent({llm:newChatOpenAI({model:'gpt-4'}),client:newMCPClient({url:'http://localhost:3000/mcp'})})awaitdba.run('Show me all users who signed up this week')awaitdba.run('Optimize the slow queries in the performance log')
A typical MCP-Use project structure:
my-mcp-app/├── src/│ └── index.ts # MCP server definition├── resources/ # UI widgets (React components)│ ├── dashboard.tsx # Main dashboard widget│ └── settings.tsx # Settings panel widget├── package.json # Dependencies and scripts├── tsconfig.json # TypeScript configuration├── .env # Environment variables└── dist/ # Build output ├── index.js # Compiled server └── resources/ # Compiled widgets# 1. Create your projectnpx create-mcp-use-app my-project# 2. Start developmentcd my-projectnpm run dev# 3. Make changes - hot reload handles the rest# 4. Test with the auto-opened inspector
# Build for productionnpm run build# Deploy with Dockerdocker build -t my-mcp-server.docker run -p 3000:3000 my-mcp-server# Or deploy to any Node.js hostnpm run start
- Discord:Join our community
- GitHub Issues:Report bugs or request features
- Documentation:Full docs
This monorepo uses modern tooling for package management:
# Create a changeset for your changespnpm changeset# Version packages based on changesetspnpm changeset version# Publish all changed packagespnpm changeset publish
# Publish individual packagespnpm --filter mcp-use publish --access publicpnpm --filter @mcp-use/cli publish --access publicpnpm --filter @mcp-use/inspector publish --access publicpnpm --filter create-mcp-use-app publish --access public# Or publish all at oncepnpm -r publish --access public
We welcome contributions! Check out ourContributing Guide to get started.
# Clone the repositorygit clone https://github.com/mcp-use/mcp-use-ts.gitcd mcp-use-ts# Install dependenciespnpm install# Build all packagespnpm build# Run testspnpmtest# Start developmentpnpm dev
MIT ©MCP-Use
Built with ❤️ by the MCP-Use team
About
mcp-use is the framework for MCP with the best DX - Build AI agents, create MCP servers with UI widgets, and debug with built-in inspector. Includes client SDK, server SDK, React hooks, and powerful dev tools.
Topics
Resources
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors6
Uh oh!
There was an error while loading.Please reload this page.