Skip to content

Commit 3549887

Browse files
committed
update pyproject script
1 parent 1ebb084 commit 3549887

File tree

4 files changed

+455
-11
lines changed

4 files changed

+455
-11
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Codegen MCP Server
2+
3+
<p align="center">
4+
<a href="https://docs.codegen.com">
5+
<img src="https://i.imgur.com/6RF9W0z.jpeg" />
6+
</a>
7+
</p>
8+
9+
<h2 align="center">
10+
An MCP server implementation that integrates the codegen sdk.
11+
12+
</h2>
13+
14+
<div align="center">
15+
16+
[![Documentation](https://img.shields.io/badge/Docs-docs.codegen.com-purple?style=flat-square)](https://docs.codegen.com)
17+
[![License](https://img.shields.io/badge/Code%20License-Apache%202.0-gray?&color=gray)](https://github.com/codegen-sh/codegen-sdk/tree/develop?tab=Apache-2.0-1-ov-file)
18+
19+
</div>
20+
21+
This example demonstrates how to run a Model Control Protocol (MCP) server that integrates with Codegen. The server provides:
22+
23+
1. A standardized interface for model inference
24+
2. Integration with Codegen's core functionality, parsing codebases and executing codemods
25+
3. Support for various LLM providers through the MCP protocol
26+
27+
28+
## Quick Start
29+
30+
### Prerequisites
31+
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
32+
- [python](https://www.python.org/downloads/) 3.12+
33+
34+
35+
### Direct Execution
36+
37+
1. No installation is necessary, with the following command. Run this command directly or add it your `.json` mcp config file.
38+
39+
```bash
40+
uvx --from 'git+https://github.com/codegen-sh/codegen-sdk.git@ce8cffe#egg=codegen-mcp-server&subdirectory=codegen-examples/examples/codegen-mcp-server' codegen-mcp-server
41+
```
42+
43+
44+
### Example MCP Config
45+
Here is an example mcp config that can be used with Cline or Claude desktop to integrate this MCP server
46+
47+
```json
48+
{
49+
"mcpServers": {
50+
"codegen-mcp": {
51+
"command": "uvx",
52+
"args": [
53+
"--from", "git+https://github.com/codegen-sh/codegen-sdk.git#egg=codegen-mcp-server&subdirectory=codegen-examples/examples/codegen-mcp-server", "codegen-mcp-server"
54+
],
55+
"disabled": false,
56+
"autoApprove": []
57+
}
58+
}
59+
}
60+
61+
```

codegen-examples/examples/codegen-mcp-server/pyproject.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ description = "MCP server implementation adding tools for the Codegen SDK"
55
readme = "README.md"
66
requires-python = ">=3.12"
77
dependencies = [
8-
"codegen>=0.14.5",
9-
"fastmcp>=1.2.1",
10-
"uvicorn>=0.27.1",
11-
"fastapi>=0.110.0",
12-
"pydantic>=2.6.3",
13-
"rich>=13.7.1",
14-
"click>=8.1.7",
8+
"codegen>=0.14.5",
9+
"uvicorn>=0.27.1",
10+
"fastapi>=0.110.0",
11+
"pydantic>=2.6.3",
12+
"rich>=13.7.1",
13+
"click>=8.1.7",
14+
"mcp[cli]>=1.2.1",
1515
]
1616

1717
[tool.poetry.scripts]
1818
codegen-mcp-server = "server:main"
19+
[project.scripts]
20+
codegen-mcp-server = "server:main"

codegen-examples/examples/codegen-mcp-server/server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,12 @@ async def execute_codemod(codemod: Annotated[str, "The python codemod code to ex
8282
return {"error": f"Error executing codemod: {str(e)}", "details": {"type": type(e).__name__, "message": str(e)}}
8383

8484

85-
if __name__ == "__main__":
85+
def main():
8686
print("starting codegen-mcp-server")
8787
run = mcp.run_stdio_async()
8888
print("codegen-mcp-server started")
8989
asyncio.run(run)
90+
91+
92+
if __name__ == "__main__":
93+
main()

0 commit comments

Comments
 (0)