- Notifications
You must be signed in to change notification settings - Fork1k
mcp-use is the easiest way to interact with mcp servers with custom agents
License
mcp-use/mcp-use
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
mcp-use provides everything you need to build withModel Context Protocol
MCP servers, MCP clients and AI agents in 6 lines of code, in bothPython andTypeScript.
- 🤖 MCP Agents - AI agents that can use tools and reason across steps
- 🔌 MCP Clients - Connect any LLM to any MCP server
- 🛠️ MCP Servers - Build your own MCP servers
- 🔍 MCP Inspector - Web-based debugger for MCP servers
- 🎨 MCP-UI Resources - Build ChatGPT apps with interactive widgets
Create intelligent agents that can use tools, browse the web, manage files, and more. | Connect directly to MCP servers and call tools programmatically without an agent. |
Build your own MCP servers with tools, resources, and prompts. | Test, debug, and explore your MCP servers interactively. |
Create interactive UIs with mcp-ui, react and live reload. | Deploy and manage your MCP agents and servers in the cloud. |
Create an AI agent that can use MCP tools to accomplish complex tasks.
pip install mcp-use langchain-openai
importasynciofromlangchain_openaiimportChatOpenAIfrommcp_useimportMCPAgent,MCPClientasyncdefmain():# Configure MCP serverconfig= {"mcpServers": {"filesystem": {"command":"npx","args": ["-y","@modelcontextprotocol/server-filesystem","/tmp"] } } }client=MCPClient.from_dict(config)llm=ChatOpenAI(model="gpt-4o")agent=MCPAgent(llm=llm,client=client)result=awaitagent.run("List all files in the directory")print(result)asyncio.run(main())
→ Full Python Agent Documentation
npm install mcp-use @langchain/openai
import{ChatOpenAI}from"@langchain/openai";import{MCPAgent,MCPClient}from"mcp-use";asyncfunctionmain(){// Configure MCP serverconstconfig={mcpServers:{filesystem:{command:"npx",args:["-y","@modelcontextprotocol/server-filesystem","/tmp"],},},};constclient=MCPClient.fromDict(config);constllm=newChatOpenAI({modelName:"gpt-4o"});constagent=newMCPAgent({ llm, client});constresult=awaitagent.run("List all files in the directory");console.log(result);}main();
→ Full TypeScript Agent Documentation
Connect to MCP servers directly without an AI agent for programmatic tool access.
importasynciofrommcp_useimportMCPClientasyncdefmain():config= {"mcpServers": {"calculator": {"command":"npx","args": ["-y","@modelcontextprotocol/server-everything"] } } }client=MCPClient.from_dict(config)awaitclient.create_all_sessions()session=client.get_session("calculator")result=awaitsession.call_tool(name="add",arguments={"a":5,"b":3})print(f"Result:{result.content[0].text}")awaitclient.close_all_sessions()asyncio.run(main())
import{MCPClient}from"mcp-use";asyncfunctionmain(){constconfig={mcpServers:{calculator:{command:"npx",args:["-y","@modelcontextprotocol/server-everything"],},},};constclient=newMCPClient(config);awaitclient.createAllSessions();constsession=client.getSession("calculator");constresult=awaitsession.callTool("add",{a:5,b:3});console.log(`Result:${result.content[0].text}`);awaitclient.closeAllSessions();}main();
→ TypeScript Client Documentation
Build your own MCP server with custom tools, resources, and prompts.
npx create-mcp-use-app my-servercd my-servernpm installimport{createMCPServer}from"mcp-use/server";import{z}from"zod";constserver=createMCPServer("my-server",{version:"1.0.0",description:"My custom MCP server",});// Define a toolserver.tool("get_weather",{description:"Get weather for a city",parameters:z.object({city:z.string().describe("City name"),}),execute:async({ city})=>{return{temperature:72,condition:"sunny", city};},});// Start server with auto-inspectorserver.listen(3000);// 🎉 Inspector at http://localhost:3000/inspector
→ Full TypeScript Server Documentation
Coming Soon! For now, please use the TypeScript implementation to create MCP servers.
Debug and test your MCP servers with the interactive web-based inspector.
When you create a server withmcp-use, the inspector is automatically available:
server.listen(3000);// Inspector automatically at: http://localhost:3000/inspector
Inspect any MCP server via CLI:
npx @mcp-use/inspector --url http://localhost:3000/sse
Features:
- 🔍 Test tools interactively with live execution
- 📊 Monitor connection status and server health
- 🔐 Handle OAuth flows automatically
- 💾 Persistent sessions with localStorage
→ Full Inspector Documentation
- Web Browsing with Playwright - Automate browser tasks
- Multi-Server Setup - Use multiple MCP servers together
- Streaming Responses - Real-time agent output
- UI Widgets - Build interactive React components
- AI SDK Integration - Vercel AI SDK for Next.js apps
- 📘 Python Documentation - Complete Python guide
- 📗 TypeScript Documentation - Complete TypeScript guide
- 🔍 Inspector Documentation - Inspector guide
- 🌐 Online Docs - Full online documentation
| Feature | Description | Python | TypeScript |
|---|---|---|---|
| 🤖 MCP Agents | AI agents with tool access and multi-step reasoning | ✅ | ✅ |
| 🔌 MCP Clients | Direct connection to any MCP server | ✅ | ✅ |
| 🛠️ MCP Servers | Build custom MCP servers | 🔜 | ✅ |
| 🔍 Inspector | Web-based debugging tool | ✅ | ✅ |
| 🎨 UI Widgets | Build interactive React UIs | ➖ | ✅ |
| 🌐 Multi-Server | Connect to multiple servers simultaneously | ✅ | ✅ |
| 📡 Streaming | Real-time streaming responses | ✅ | ✅ |
| 📊 Observability | Built-in Langfuse integration | ✅ | ✅ |
| 🔐 OAuth Support | Built-in OAuth flow handling | ✅ | ✅ |
| 🛡️ Tool Control | Restrict access to specific tools | ✅ | ✅ |
This monorepo contains multiple packages for both Python and TypeScript:
| Package | Description | Version |
|---|---|---|
| mcp-use | Complete MCP client and agent library |
mcp-use/├── libraries/│ ├── python/ → Python implementation│ │ ├── mcp_use/ → Core library│ │ ├── examples/ → Python examples│ │ └── docs/ → Python documentation│ ││ └── typescript/ → TypeScript implementation│ └── packages/│ ├── mcp-use/ → Core framework│ ├── cli/ → Build tool│ ├── inspector/ → Web inspector│ └── create-mcp-use-app/ → Scaffolding└── README.md → This fileBuild everything from AI agents to servers - not just clients. Create the full MCP ecosystem in your preferred language.
Choose Python for ML/data workflows or TypeScript for web applications. Same great features, different languages.
Includes observability, streaming, multi-server support, sandboxing, and tool access controls out of the box.
Hot reload, TypeScript/Python type safety, built-in inspector, and comprehensive documentation.
MIT licensed and community-driven. Contribute, fork, or extend as needed.
- 💬 Discord:Join our community
- 🐛 GitHub Issues:Report bugs or request features
- 📖 Documentation:docs.mcp-use.com
- 🌐 Website:mcp-use.com
- 🐦 Twitter: Follow@pietrozullo and@pederzh
MIT ©MCP-Use Contributors
We love contributions! Check out our contributing guidelines:
If you use MCP-Use in your research or project, please cite:
@software{mcp_use2025,author ={Zullo, Pietro and Contributors},title ={MCP-Use: Complete MCP Ecosystem for Python and TypeScript},year ={2025},publisher ={GitHub},url ={https://github.com/mcp-use/mcp-use}}
Thanks to all our amazing contributors!
- Pietro (@pietrozullo)
- Luigi (@pederzh)
- Enrico (@tonxxd)
San Francisco | Zürich
About
mcp-use is the easiest way to interact with mcp servers with custom agents
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.