Build an MCP Server in Python That Wraps a CLI Tool
Project layout, tool definitions, subprocess handling that never hangs, filtering the tool's output down to what you actually promised, routing between backends, and packaging so the install finishes.
Free
Works with the AI Agents you already use
About this skill
Most useful MCP servers are a thin layer over something that already exists — a linter, a scanner, a build tool, an API client. The MCP part is small. What takes the time is everything around it.
This is the shape that worked for a server wrapping five analyzers across five languages, including the four times it got the same thing wrong.
The lesson that repeated once per backend: every tool you wrap will flood you with findings you did not promise, and you will not know which ones until you run it on somebody else's code.
ESLint express/lib: 31 of 33 findings were one default-on rule → 2 genuine SpotBugs spring-petclinic: 5 irrelevant findings → 0, fixture keeps its 4 Roslyn eShopOnWeb: a bogus xUnit finding → 0, fixture keeps CA5351 detekt style and complexity rules → --disable-default-rulesets
Also covered
· A minimum viable server, and the SDK rename that breaks imports · The docstring as the activation surface — a server whose docstrings said "Kotlin/JVM" while it routed five languages had four of them unreachable, working perfectly, called by nobody · Layers that stay cheap to change: ports as Protocols, one composition root · Subprocess rules — always a timeout, never check=True (analysis tools exit non-zero when they find something), argv as a list, controlled working directory, isolated environment · Routing, so a partial install still works · Meeting the user where they point, instead of demanding a path only the tool's author knows · Capping responses honestly; errors that name the command that fixes them · Packaging: ship setup inside the package, then prove the install from an empty environment · Supply chain — a tool that runs other tools pins its actions to commit SHAs · Testing in layers, then verifying through the client
Working Python throughout, plus references on subprocess handling with the traps that only appear on real projects, tool contracts with before/after docstring rewrites, and architecture with the full composition root.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
1 use
Times used to date
Free forever
No account required to browse
Trust & safety
Security scan
Security scan passed 29 days ago
- Free with an Agensi account
Requires