CosmWasm MCP Server Template
@archway-network
MCP server template for CosmWasm smart contract projects
Overview
What is CosmWasm MCP Server Template?
A Rust-based MCP (Model Context Protocol) server template that wraps query and execute entry point messages from any CosmWasm smart contract so they can be broadcast by a signer. It is designed for developers who want to enable AI agents to interact with their CosmWasm contracts via MCP tools.
How to use CosmWasm MCP Server Template?
Build the project using the Rust nightly channel (rustup default nightly) and run cargo build or cargo build --release. To customize the template for your own contract, update the contract dependency in Cargo.toml, modify src/server.rs to import your contract’s QueryMsg and ExecuteMsg, and set the deployed contract addresses in src/contract.rs. Optional steps include enabling MCP tools for custom types, customizing LLM instructions in src/instruction.rs, and choosing a transport mode (stdio, sse, or http-streamable).
Key features of CosmWasm MCP Server Template
- Ships with six built‑in MCP tools for contract interaction
- Works with any CosmWasm contract after minimal configuration
- Supports three transport modes: stdio, sse, and http-streamable
- Automatically generates JSON schemas from doc comments for better AI accuracy
- Allows multi‑contract support through namespacing and pattern matching
- Provides LLM instruction customization in dedicated source files
Use cases of CosmWasm MCP Server Template
- Enable an AI agent to query on‑chain state from a CosmWasm contract
- Allow agents to build and broadcast transactions to a contract
- Rapidly prototype an MCP server for an existing CosmWasm dApp
- Build a tool that lists contract deployments, entry points, and NFTs
- Create a unified interface for multi‑contract systems
FAQ from CosmWasm MCP Server Template
What transport modes does the server support?
The template supports three transport modes: stdio (default), sse (server‑side events), and http‑streamable.
What tools are provided by default?
It provides six tools: list_contract_deployments, list_nft_collections, list_query_entry_points, build_query_msg, list_tx_entry_points, and build_execute_msg.
How do I connect the server to Claude Desktop?
Build a release binary, then point the MCP server’s command in claude_desktop_config.json to the binary path. No run arguments are required for stdio mode. For WSL users, execute the VM as the command and pass the binary path in args.
How can I improve AI accuracy when using this template?
Add doc comments (triple‑slash ///) to your contract’s msg::QueryMsg and msg::ExecuteMsg types. These comments are embedded into JSON schemas by schemars, helping the LLM interpret entry points correctly.
What are the build requirements?
The project requires the Rust nightly toolchain because it uses edition 2024. Build with cargo build for development or cargo build --release for deployment.