Repository navigation
MCP_Server_VSCode
The SDK comes with an optional MCP server, ur-mcp, which exposes the codec to AI agents (like GitHub Copilot in VS Code) over stdio. It is side-effect free: its tools only inspect or derive Universal Router data, they never sign or broadcast a transaction.
The MCP server is an optional extra of the SDK:
pip install 'uniswap-universal-router-decoder[mcp]'This installs the ur-mcp command in your environment. The quotes around the package name are needed for your shell to not interpret the brackets.
VS Code reads its MCP servers from a mcp.json file, either in your workspace (.vscode/mcp.json) or in your user profile. Open the workspace one with the MCP: Open Workspace Folder MCP Configuration command, and add the following entry:
{
"servers": {
"uniswap-universal-router-decoder": {
"type": "stdio",
"command": "ur-mcp",
"env": {
"RPC_URL": "https://..."
}
}
}
}A few notes:
-
commandcan beur-mcpif it is on yourPATH, or the absolute path tour-mcpin your virtual environment (ex:/path/to/venv/bin/ur-mcp). -
RPC_URLis optional: only thedecode_transactiontool needs it. It can also be provided asETH_RPC_URL, or per call through therpc_urltool argument.
Instead of editing the file by hand, you can add the server from a terminal with the code --add-mcp command:
code --add-mcp '{"name":"uniswap-universal-router-decoder","type":"stdio","command":"uvx","args":["--from","uniswap-universal-router-decoder[mcp]","ur-mcp"]}'This adds the server to your VS Code user-profile configuration, using the VS Code format. An env object can be added the same way as in the file.
If you don't want to install the SDK in your environment, you can let uv run the server on the fly:
{
"servers": {
"uniswap-universal-router-decoder": {
"type": "stdio",
"command": "uvx",
"args": ["--from", "uniswap-universal-router-decoder[mcp]", "ur-mcp"],
"env": {
"RPC_URL": "https://..."
}
}
}
}VS Code also supports the portable .mcp.json format, at the root of your workspace, which uses a top-level mcpServers object i/o servers:
{
"mcpServers": {
"uniswap-universal-router-decoder": {
"command": "ur-mcp",
"env": {
"RPC_URL": "https://..."
}
}
}
}Run the MCP: List Servers command from the Command Palette and check that the server is running. You can also start, stop or restart it from there.
The server provides eight tools:
-
list_commands/describe_command: discover the decoded call format and the commands -
decode_transaction: fetch and decode a transaction sent to the UR (needs an RPC endpoint) -
decode_calldata,encode_calldata,decode_error,decode_v3_path,encode_v3_path: decode or encode data without an RPC endpoint
encode_calldata is the mirror of decode_calldata: it rebuilds the calldata from a decoded call, so an agent can decode a route, edit it and re-encode it.
The tools are annotated as read-only, so VS Code can auto-approve them i/o prompting on every call.
And that's it! Your VS Code agent can now decode and encode Universal Router data for you.
See also How to install and configure the SDK MCP server in Zed ? for the Zed setup.
If you find this library useful, consider a donation and be part of the Supporter Community! :)
- ☕️☕️☕️ https://www.buymeacoffee.com/elnaril ☕️☕️☕️
- Ethereum compatible: 0xe32A121C89121bF8B829D6d88BBEA89e5d88f002
- Sponsoring: https://github.com/sponsors/Elnaril
Thank you to all supporters!! 🙏
Also, consider ⭐ starring ⭐ the repository and following the GitHub account and/or 𝕏 to get the next lib updates!