Skip to content
Back to search

automcp

Easily convert tool, agents and orchestrators from existing agent frameworks to MCP servers

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/napthaai--automcp/badge.svg)](/listings/napthaai--automcp)

HTML

<a href="/listings/napthaai--automcp"><img src="/api/listings/napthaai--automcp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Install from PyPI:

# Basic installation
pip install naptha-automcp

# UV
uv add naptha-automcp

Or install from source:

git clone https://github.com/napthaai/automcp.git
cd automcp
uv venv 
source .venv/bin/activate
pip install -e .

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 466 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # automcp
  2. ## 🚀 Overview
  3. automcp allows you to easily convert tools, agents and orchestrators from existing agent frameworks into [MCP](https://modelcontextprotocol.io/introduction) servers, that can then be accessed by standardized interfaces via clients like Cursor and Claude Desktop.
  4. We currently support deployment of agents, tools, and orchestrators as MCP servers for the following agent frameworks:
  5. 1. CrewAI
  6. 2. LangGraph
  7. 3. Llama Index
  8. 4. OpenAI Agents SDK
  9. 5. Pydantic AI
  10. 6. mcp-agent
  11. ## 🔧 Installation
  12. Install from PyPI:
  13. ```bash
  14. # Basic installation
  15. pip install naptha-automcp
  16. # UV
  17. uv add naptha-automcp
  18. ```
  19. Or install from source:
  20. ```bash
  21. git clone https://github.com/napthaai/automcp.git
  22. cd automcp
  23. uv venv
  24. source .venv/bin/activate
  25. pip install -e .
  26. ```
  27. ## 🧩 Quick Start
  28. Create a new MCP server for your project:
  29. Navigate to your project directory with your agent implementation:
  30. ```bash
  31. cd your-project-directory
  32. ```
  33. Generate the MCP server files via CLI with one of the following flags (crewai, langgraph, llamaindex, openai, pydantic, mcp_agent):
  34. ```bash
  35. automcp init -f crewai
  36. ```
  37. Edit the generated `run_mcp.py` file to configure your agent:
  38. ```python
  39. # Replace these imports with your actual agent classes
  40. from your_module import YourCrewClass
  41. # Define the input schema
  42. class InputSchema(BaseModel):
  43. parameter1: str
  44. parameter2: str
  45. # Set your agent details
  46. name = "<YOUR_AGENT_NAME>"
  47. description = "<YOUR_AGENT_DESCRIPTION>"
  48. # For CrewAI projects
  49. mcp_crewai = create_crewai_adapter(
  50. orchestrator_instance=YourCrewClass().crew(),
  51. name=name,
  52. description=description,
  53. input_schema=InputSchema,
  54. )
  55. ```
  56. Install dependencies and run your MCP server:
  57. ```bash
  58. automcp serve -t sse
  59. ```
  60. ## 📁 Generated Files
  61. When you run `automcp init -f <FRAMEWORK>`, the following file is generated:
  62. ### run_mcp.py
  63. This is the main file that sets up and runs your MCP server. It contains:
  64. - Server initialization code
  65. - STDIO and SSE transport handlers
  66. - A placeholder for your agent implementation
  67. - Utilities to suppress warnings that might corrupt the STDIO protocol
  68. You'll need to edit this file to:
  69. - Import your agent/crew classes
  70. - Define your input schema (the parameters your agent accepts)
  71. - Configure the adapter with your agent
  72. ## 🔍 Examples
  73. ### Running the examples
  74. The repository includes examples for each supported framework:
  75. ```bash
  76. # Clone the repository
  77. git clone https://github.com/NapthaAI/automcp.git
  78. cd automcp
  79. # Install automcp in development mode
  80. pip install -e .
  81. # Navigate to an example directory
  82. cd examples/crewai/marketing_agents
  83. # Generate the MCP server files (use the appropriate framework)
  84. automcp init -f crewai
  85. # Edit the generated run_mcp.py file to import and configure the example agent
  86. # (See the specific example's README for details)
  87. # Add a .env file with necessary environmental variables
  88. # Install dependencies and run
  89. automcp serve -t sse
  90. ```
  91. Each example follows the same workflow as a regular project:
  92. 1. Run `automcp init -f <FRAMEWORK>` to generate the server files
  93. 2. Edit `run_mcp.py` to import and configure the example agent
  94. 3. Add a .env file with necessary environmental variables
  95. 4. Install dependencies and serve using `automcp serve -t sse`
  96. ### CrewAI example
  97. Here's what a typical configured `run_mcp.py` looks like for a CrewAI example:
  98. ```python
  99. import warnings
  100. from typing import Any
  101. from automcp.adapters.crewai import create_crewai_adapter
  102. from pydantic import BaseModel
  103. from mcp.server.fastmcp import FastMCP
  104. mcp = FastMCP("MCP Server")
  105. warnings.filterwarnings("ignore")
  106. from crew import MarketingPostsCrew
  107. class InputSchema(BaseModel):
  108. project_description: str
  109. customer_domain: str
  110. name = "marketing_posts_crew"
  111. description = "A crew that posts marketing posts to a social media platform"
  112. # Create an adapter for crewai
  113. mcp_crewai = create_crewai_adapter(
  114. orchestrator_instance=MarketingPostsCrew().crew(),
  115. name=name,
  116. description=description,
  117. input_schema=InputSchema,
  118. )
  119. mcp.add_tool(
  120. mcp_crewai,
  121. name=name,
  122. description=description
  123. )
  124. # Server entrypoints
  125. def serve_sse():
  126. mcp.run(transport="sse")
  127. def serve_stdio():
  128. # Redirect stderr to suppress warnings that bypass the filters
  129. import os
  130. import sys
  131. class NullWriter:
  132. def write(self, *args, **kwargs):
  133. pass
  134. def flush(self, *args, **kwargs):
  135. pass
  136. # Save the original stderr
  137. original_stderr = sys.stderr
  138. # Replace stderr with our null writer to prevent warnings from corrupting STDIO
  139. sys.stderr = NullWriter()
  140. # Set environment variable to ignore Python warnings
  141. os.environ["PYTHONWARNINGS"] = "ignore"
  142. try:
  143. mcp.run(transport="stdio")
  144. finally:
  145. # Restore stderr for normal operation
  146. sys.stderr = original_stderr
  147. if __name__ == "__main__":
  148. import sys
  149. if len(sys.argv) > 1 and sys.argv[1] == "sse":
  150. serve_sse()
  151. else:
  152. serve_stdio()
  153. ```
  154. ## 🔄 Running Your MCP Server
  155. After setting up your files, you can run your server using one of these methods:
  156. ```bash
  157. # Using the automcp CLI
  158. automcp serve -t stdio # STDIO transport
  159. automcp serve -t sse # SSE transport
  160. # Or run the Python file directly
  161. python run_mcp.py # STDIO transport
  162. python run_mcp.py sse # SSE transport
  163. # Or with uv run (if configured in pyproject.toml)
  164. uv run serve_stdio
  165. uv run serve_sse
  166. ```
  167. **Note about transport modes:**
  168. - **STDIO**: You don't need to run the server manually - it will be started by the client (Cursor)
  169. - **SSE**: This is a two-step process:
  170. 1. Start the server separately: `python run_mcp.py sse` or `automcp serve -t sse`
  171. 2. Add the mcp.json configuration to connect to the running server
  172. If you want to use the `uv run` commands, add the following to your `pyproject.toml`:
  173. ```toml
  174. [tool.uv.scripts]
  175. serve_stdio = "python run_mcp.py"
  176. serve_sse = "python run_mcp.py sse"
  177. ```
  178. ## ☁️ Deploying with Naptha's MCPaaS
  179. Naptha supports deploying your newly-created MCP server to our MCP servers-as-a-service platform! It's easy to get started.
  180. ### Setup
  181. Naptha's MCPaaS platform requires your repository be set up with `uv`.
  182. This means you need a couple configurations in your `pyproject.toml`.
  183. First, make sure the `run_mcp.py` file generated by `naptha-automcp` is the root of your repository.
  184. Second, make sure your `pyproject.toml` has the following configurations:
  185. ```toml
  186. [build-system]
  187. requires = [ "hatchling",]
  188. build-backend = "hatchling.build"
  189. [project.scripts]
  190. serve_stdio = "run_mcp:serve_stdio"
  191. serve_sse = "run_mcp:serve_sse"
  192. [tool.hatch.metadata]
  193. allow-direct-references = true
  194. [tool.hatch.build.targets.wheel]
  195. include = [ "run_mcp.py",]
  196. exclude = [ "__pycache__", "*.pyc",]
  197. sources = [ ".",]
  198. packages = ["."]
  199. ```
  200. If your agent is in a subdirectory / package of your repository:
  201. ```
  202. pyproject.toml
  203. run_mcp.py
  204. my_agent/
  205. |---| __init__.py
  206. | agent.py
  207. ```
  208. Make sure that it's imported like this in `run_mcp.py`:
  209. ```python
  210. from my_agent.agent
  211. ```
  212. Not like below, since this will cause the build to fail:
  213. ```python
  214. from .my_agent.agent
  215. ```
  216. Once you have configured everything, commit and push your code (but not your environment variables!) to github. Then, you can test it to make sure you set up everything correctly:
  217. ```shell
  218. uvx --from https://github.com/your-username/your-repo serve_sse
  219. ```
  220. If this results in your MCP server being launched on port 8000 successfully, you're good to go!
  221. ### Launching your server
  222. 1. go to [labs.naptha.ai](https://labs.naptha.ai)
  223. 2. Sign in with your github account
  224. 3. Pick the repository you edited from your repository list -- we autodiscover your github repos.
  225. 4. add your environment variables e.g. `OPENAI_API_KEY`, etc.
  226. 5. Click Launch.
  227. 6. Copy the SSE URL, and paste it into your MCP client:
  228. ## 🔌 Using with MCP Clients
  229. ### Cursor
  230. To integrate with Cursor IDE, create a `.cursor` folder in your project root and add an `mcp.json` file with the following configuration:
  231. ```json
  232. {
  233. "mcpServers": {
  234. "crew-name-stdio": {
  235. "type": "stdio",
  236. "command": "/absolute/path/to/your/.venv/bin/uv",
  237. "args": [
  238. "--directory",
  239. "/absolute/path/to/your/project_dir",
  240. "run",
  241. "serve_stdio"
  242. ],
  243. "env": {
  244. "OPENAI_API_KEY": "sk-",
  245. "SERPER_API_KEY": ""
  246. }
  247. },
  248. "crew-name-python": {
  249. "type": "stdio",
  250. "command": "/absolute/path/to/your/.venv/bin/python",
  251. "args": [
  252. "/absolute/path/to/your/project_dir/run_mcp.py"
  253. ],
  254. "env": {
  255. "OPENAI_API_KEY": "sk-",
  256. "SERPER_API_KEY": ""
  257. }
  258. },
  259. "crew-name-automcp": {
  260. "type": "stdio",
  261. "command": "/absolute/path/to/your/.venv/bin/automcp",
  262. "args": [
  263. "serve",
  264. "-t",
  265. "stdio"
  266. ],
  267. "cwd": "/absolute/path/to/your/project_dir",
  268. "env": {
  269. "OPENAI_API_KEY": "sk-",
  270. "SERPER_API_KEY": ""
  271. }
  272. },
  273. "crew-name-sse": {
  274. "type": "sse",
  275. "url": "http://localhost:8000/sse"
  276. }
  277. }
  278. }
  279. ```
  280. **Note:** Be sure to replace all placeholder paths with absolute paths to your actual files and directories.
  281. ### Direct GitHub Execution
  282. Push your project to GitHub and use:
  283. ```json
  284. {
  285. "mcpServers": {
  286. "My Agent": {
  287. "command": "uvx",
  288. "args": [
  289. "--from",
  290. "git+https://github.com/your-username/your-repo",
  291. "serve_stdio"
  292. ],
  293. "env": {
  294. "OPENAI_API_KEY": "your-key-here"
  295. }
  296. }
  297. }
  298. }
  299. ```
  300. ## 🛠️ Creating New Adapters
  301. Want to add support for a new agent framework? Here's how:
  302. 1. Create a new adapter file in automcp/adapters/ (or add to an existing framework file):
  303. ```python
  304. # automcp/adapters/framework.py
  305. import json
  306. import contextlib
  307. import io
  308. from typing import Any, Callable, Type
  309. from pydantic import BaseModel
  310. def create_framework_adapter(
  311. agent_instance: Any,
  312. name: str,
  313. description: str,
  314. input_schema: Type[BaseModel],
  315. ) -> Callable:
  316. """Doc string for your function"""
  317. # Get the field names and types from the input schema
  318. schema_fields = input_schema.model_fields
  319. # Create the parameter string for the function signature
  320. params_str = ", ".join(
  321. f"{field_name}: {field_info.annotation.__name__}"
  322. for field_name, field_info in schema_fields.items()
  323. )
  324. # Create the function body that constructs the input schema
  325. # Note: You may need to adjust the method calls (kickoff, model_dump_json)
  326. # to match your framework's specific API
  327. body_str = f"""def run_agent({params_str}):
  328. inputs = input_schema({', '.join(f'{name}={name}' for name in schema_fields)})
  329. with contextlib.redirect_stdout(io.StringIO()):
  330. result = agent_instance.framework_specific_run(inputs=inputs.model_dump())
  331. return result.framework_specific_result()
  332. """
  333. # Create a namespace for the function
  334. namespace = {
  335. "input_schema": input_schema,
  336. "agent_instance": agent_instance,
  337. "json": json,
  338. "contextlib": contextlib,
  339. "io": io,
  340. }
  341. # Execute the function definition in the namespace
  342. exec(body_str, namespace)
  343. # Get the created function
  344. run_agent = namespace["run_agent"]
  345. # Add proper function metadata
  346. run_agent.__name__ = name
  347. run_agent.__doc__ = description
  348. return run_agent
  349. ```
  350. 2. Create an example in examples/your_framework/
  351. ## 📝 Notes
  352. - When working with STDIO transport, be careful with print statements in your agent code as they can corrupt the protocol
  353. - The MCP Inspector can be used for debugging: `npx @modelcontextprotocol/inspector`
  354. - Remember that for STDIO mode, the client (like Cursor) will start the server for you
  355. - For SSE mode, you need to manually start the server and then configure the client to connect to it

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.