In the rapidly evolving world of AI and server interactions, developers need tools that simplify complex workflows while offering flexibility and power. Enter MCP-Use, a full-stack framework designed to streamline interactions with the Model Context Protocol (MCP). Whether you’re building AI agents, connecting to MCP clients, or creating custom MCP servers, MCP-Use provides a comprehensive ecosystem for both Python and TypeScript developers. In this blog post, we’ll explore what makes MCP-Use a game-changer, leveraging its open source nature, multi-server support, streaming responses, and exceptional developer experience.
What is MCP-Use?
MCP-Use is an open source framework that empowers developers to build, connect, and debug applications using the Model Context Protocol (MCP). It’s designed to be a one-stop shop for creating AI agents, MCP clients, custom MCP servers, and even interactive UI widgets. With support for both Python and TypeScript, MCP-Use caters to a wide range of developers, from those working on machine learning pipelines to those building web applications. Its community-driven approach, hosted on the GitHub repository, ensures continuous improvement and collaboration.
Key Features of MCP-Use
MCP-Use stands out with its robust feature set, making it suitable for both prototyping and production-ready applications. Here’s a quick overview of its key features:
- AI Agents: Build AI agents that can reason across multiple steps and use tools to accomplish complex tasks.
- MCP Clients: Connect any large language model (LLM) to MCP servers for programmatic tool access.
- MCP Servers: Create custom MCP servers with tailored tools, resources, and prompts.
- MCP Inspector: A web-based debugging tool to test and monitor MCP servers interactively.
- UI Widgets: Develop interactive React-based UI widgets for ChatGPT-like applications (TypeScript-specific).
- Multi-Server Support: Connect to multiple MCP servers simultaneously for enhanced flexibility.
- Streaming Responses: Real-time streaming responses for dynamic interactions.
- Observability: Built-in Langfuse integration for robust monitoring and analytics.
- OAuth Support: Seamless handling of OAuth support for secure connections.
- Tool Control: Restrict access to specific tools for enhanced security with tool control.
Why Choose MCP-Use?
1. Complete Vertical Stack
Unlike other frameworks that focus solely on clients or agents, MCP-Use provides a full-stack framework to build an entire MCP ecosystem. From AI agents to custom MCP servers, you can create end-to-end solutions without cobbling together disparate tools. Its multi-server support allows seamless integration with multiple servers, enhancing scalability.
2. Language Flexibility
Whether you prefer Python for its dominance in ML and data science or TypeScript for web development, MCP-Use has you covered. Both implementations offer the same core features, ensuring you can work in your preferred language without sacrificing functionality. This language flexibility makes it ideal for diverse development needs.
3. Production-Ready
MCP-Use is built with production in mind. Features like observability through Langfuse integration, streaming responses, tool control, and OAuth support make it suitable for enterprise-grade applications. Its hot reload and type safety in both Python and TypeScript enhance the developer experience, reducing errors and speeding up iteration.
4. Open Source and Community-Driven
Licensed under MIT, MCP-Use is fully open source and community-driven. Hosted on its GitHub repository, it welcomes contributions from developers worldwide. Whether you’re fixing bugs, adding features, or sharing examples, you can help shape the future of this powerful framework.
Getting Started with MCP-Use
MCP-Use makes it easy to dive in, whether you’re building AI agents, connecting to MCP clients, or creating custom MCP servers. Below are some quick examples to get you started, showcasing its language flexibility.
Building an AI Agent
Create an AI agent that interacts with MCP tools to perform tasks like listing files in a directory.
Python Example
pip install mcp-use langchain-openai
import asyncio
from langchain_openai import ChatOpenAI
from mcp_use import MCPAgent, MCPClient
async def main():
config = {
"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 = await agent.run("List all files in the directory")
print(result)
asyncio.run(main())
TypeScript Example
npm install mcp-use @langchain/openai
import { ChatOpenAI } from "@langchain/openai";
import { MCPAgent, MCPClient } from "mcp-use";
async function main() {
const config = {
mcpServers: {
filesystem: {
command: "npx",
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
},
},
};
const client = MCPClient.fromDict(config);
const llm = new ChatOpenAI({ modelName: "gpt-4o" });
const agent = new MCPAgent({ llm, client });
const result = await agent.run("List all files in the directory");
console.log(result);
}
main();
Using the MCP Client
For direct access to MCP servers without an AI agent, the MCP Client is your go-to tool, enhanced by tool control for secure operations.
Python Example
import asyncio
from mcp_use import MCPClient
async def main():
config = {
"mcpServers": {
"calculator": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-everything"]
}
}
}
client = MCPClient.from_dict(config)
await client.create_all_sessions()
session = client.get_session("calculator")
result = await session.call_tool(name="add", arguments={"a": 5, "b": 3})
print(f"Result: {result.content[0].text}")
await client.close_all_sessions()
asyncio.run(main())
Creating a Custom MCP Server
Build your own MCP server with custom tools, like a weather lookup tool, leveraging TypeScript for web applications.
TypeScript Example
npx create-mcp-use-app my-server
cd my-server
npm install
import { createMCPServer } from "mcp-use/server";
import { z } from "zod";
const server = createMCPServer("my-server", {
version: "1.0.0",
description: "My custom MCP server",
});
server.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 };
},
});
server.listen(3000);
Debugging with the MCP Inspector
The MCP Inspector is a web-based tool for testing and debugging MCP servers. It’s automatically available when you run an MCP server or can be launched standalone, benefiting from OAuth support and observability:
npx @mcp-use/inspector --url http://localhost:3000/sse
The MCP Inspector offers live tool testing, connection monitoring, OAuth support, and persistent sessions, enhancing the developer experience.
Why Developers Love MCP-Use
MCP-Use isn’t just about functionality—it’s about making development enjoyable and efficient. With hot reload, comprehensive documentation on the GitHub repository, and the MCP Inspector, you can iterate quickly and debug with ease. The framework’s type safety in Python and TypeScript, combined with Langfuse integration for observability, ensures fewer errors and robust monitoring. Support for streaming responses and UI widgets makes it ideal for building dynamic, interactive applications.
Join the MCP-Use Community
MCP-Use is more than a full-stack framework—it’s a community-driven project. Whether you’re a seasoned developer or just getting started, you can contribute by:
- Sharing examples and tutorials on the GitHub repository
- Reporting bugs or suggesting features
- Joining the community-driven conversation
Check out the contributing guidelines and become part of the MCP-Use community today!
Conclusion
MCP-Use is a powerful, flexible, and developer-friendly full-stack framework for working with the Model Context Protocol. Whether you’re building AI agents, connecting to MCP clients, or creating custom MCP servers, MCP-Use provides everything
Comments