mcp pattern
Code reviewer — MCP filesystem + git + ReAct
An AI code reviewer that connects to local MCP servers (filesystem + git), reads diffs, and posts structured review comments. Ships in Python, TypeScript and Rust.
Highlights
- Wraps the official @modelcontextprotocol filesystem + git servers as Agentmatic tools.
- ReAct loop reads the diff, lints, then writes structured comments back.
- No platform glue — agent runs on your laptop, against your local checkout.
- Less than 150 lines per language.
What this shows
Plug into the MCP ecosystem with two lines of code. The agent boots, connects to the filesystem and git MCP servers (subprocess transport), reads the diff against main, and emits review comments. Nothing leaves your machine except the LLM call.
Architecture
Agent ──▶ MCPClient.stdio(["npx", "-y", "@modelcontextprotocol/server-filesystem"])
Agent ──▶ MCPClient.stdio(["uvx", "mcp-server-git"])
──▶ ReAct loop: read diff → lint → write review.md
Python
from agentmatic.tools.mcp import MCPClient
from agentmatic.prebuilt import create_react_agent
fs = MCPClient.stdio(["npx", "-y", "@modelcontextprotocol/server-filesystem", "/path/to/repo"])
git = MCPClient.stdio(["uvx", "mcp-server-git", "--repository", "/path/to/repo"])
tools = await fs.list_tools_as_agentmatic() + await git.list_tools_as_agentmatic()
reviewer = create_react_agent(llm=OpenAI("gpt-4o"), tools=tools)
review = await reviewer.invoke(
"Review the diff against main. Output structured comments to review.md."
)
TypeScript
import { MCPClient, createReactAgent, OpenAI } from '@agentmatic/core';
const fs = await MCPClient.stdio(['npx', '-y', '@modelcontextprotocol/server-filesystem', repo]);
const git = await MCPClient.stdio(['uvx', 'mcp-server-git', '--repository', repo]);
const tools = [...await fs.listToolsAsAgentmatic(), ...await git.listToolsAsAgentmatic()];
const reviewer = createReactAgent({ llm: new OpenAI('gpt-4o'), tools });
const review = await reviewer.invoke('Review the diff against main…');
Why MCP
You could write Python file-read tools yourself. The point of MCP is that the same tools are also usable by Claude Desktop, Cursor, Cline, and any other MCP-capable client — your dev environment and your agent share the toolchain.