MCP-Use provides an open-source client library designed to connect any large language model to various MCP tools. This empowers developers to build custom agents equipped with capabilities like web browsing and file operations—all without relying on closed-source applications. Easily get started with a simple installation and dive into innovative agent creation.
MCP-Use is an open-source client library designed to seamlessly connect any Large Language Model (LLM) to various MCP (Multi-Channel Protocol) tools, enabling the creation of custom agents with access to diverse functionalities such as web browsing and file operations. This library empowers developers to build applications without relying on closed-source or proprietary application clients.
MCP-Use can be installed via pip, allowing for quick setup and integration into existing projects. Developers can also clone the repository to install from source.
To quickly demonstrate the capabilities of MCP-Use, initiate an agent that performs a web search:
import asyncio
import os
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from mcp_use import MCPAgent, MCPClient
async def main():
load_dotenv() # Load environment variables
client = MCPClient.from_config_file("browser_mcp.json") # Initialize MCP client
llm = ChatOpenAI(model="gpt-4o") # Define the language model
agent = MCPAgent(llm=llm, client=client, max_steps=30) # Create the agent
result = await agent.run("Find the best restaurant in San Francisco USING GOOGLE SEARCH") # Execute query
print(f"\nResult: {result}")
if __name__ == "__main__":
asyncio.run(main())
The following is an example of a configuration file used for initiating an MCP Client:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"],
"env": {
"DISPLAY": ":1"
}
}
}
}
MCP-Use also supports a variety of other use cases like:
MCP-Use allows for the initialization of sessions from configuration files, making it easier to manage different server setups:
import asyncio
from mcp_use import create_session_from_config
async def main():
session = create_session_from_config("mcp-config.json") # Create a session from config
await session.initialize() # Initialize the session
await session.disconnect() # Disconnect when done
if __name__ == "__main__":
asyncio.run(main())
The roadmap includes plans to support multiple servers simultaneously and test various remote connectors, expanding the functionality of MCP-Use.
Contributions are welcome. Developers are encouraged to report bugs and submit feature requests to enhance the library's capabilities.
For academic use, cite MCP-Use as follows:
@software{mcp_use2025,
author = {Zullo, Pietro},
title = {MCP-Use: MCP Library for Python},
year = {2025},
publisher = {GitHub},
url = {https://github.com/pietrozullo/mcp-use}
}
Explore MCP-Use to enhance the capabilities of your applications with comprehensive access to tools and resources.
No comments yet.
Sign in to be the first to comment.