Secure MCP Server for Safe smart contract wallet transactions and API integration
The Safe MCP Server is an implementation of Model Context Protocol (MCP), specifically designed to facilitate secure interactions between AI applications and Safe (formerly Gnosis Safe) smart contract wallets. This server enables AI tools like Claude Desktop, Continue, Cursor, and others to connect with data sources such as smart contracts through a standardized protocol, ensuring seamless and reliable transactions.
The Safe MCP Server is equipped with several key features that make it indispensable for interoperability in the AI ecosystem. It supports querying safe transactions, retrieving multisig transaction details, decoding transaction data, and integrating with the Safe API.
The server can retrieve transactions associated with any Safe address. This functionality is crucial for understanding the history of a Safe transaction. The specific address is determined by the AI application during runtime, providing flexibility in usage scenarios.
// Example: Get all transactions for a given Safe address.
getSafeTransactions({
address: "0x123...", // Safe address as determined by LLM (Large Language Model)
limit: 100, // Optional parameter to limit the number of transactions retrieved
offset: 0, // Optional parameter to start from a specific transaction index
});
Accessing details about a specific transaction is another critical feature. Users can provide the safeTxHash (transaction hash) and get comprehensive information about the transaction.
// Example: Get details of a specific multisig transaction.
getMultisigTransaction({
safeTxHash: "0x456...", // Hash of the transaction to query
});
Decoding transaction data is essential for understanding and processing the contents. The server uses Safe API to decode raw transaction data.
// Example: Decode a transaction's data with an optional contract address.
decodeTransactionData({
data: "0x789...", // Raw transaction data to be decoded
to: "0xabc...", // Optional parameter for the contract address if required by the transaction
});
Integration with the Safe Transaction API ensures reliable and secure interactions. The server supports both mainnet and testnet environments, allowing developers to choose the appropriate environment based on their needs.
The architecture of the Safe MCP Server is designed around Model Context Protocol (MCP), which standardizes communication between AI applications and external data sources or tools. MCP ensures that interactions are secure, reliable, and interoperable across different platforms.
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
graph LR
A[Safe Address] --> B(Safe Transaction API) -->|Processed Data| C[Database]
C --> D[Application Logic] --> E[User Interface]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#e8f5e8
style D fill:#f9c74f
style E fill:#a6dba0
To get started, follow these simple steps:
Install Dependencies:
npm install
Build and Start the Server:
npm run build
npm start
The server uses the Safe Transaction API mainnet endpoint by default but can be configured to use different endpoints, such as testnets.
Imagine an AI-powered financial advisor that needs to monitor and analyze transactions for its clients. With the Safe MCP Server, this advisor can seamlessly query and retrieve transaction data from Safe addresses in real-time.
In a similar vein, a smart contract audit tool could use this server to fetch and decode transaction data automatically, providing detailed insights without manual intervention.
The Safe MCP Server is compatible with several AI tools through the MCP client compatibility matrix:
The following table provides an overview of the MCP client compatibility status:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
The server is designed to handle a wide range of AI application needs, ensuring robust performance and compatibility across different environments. The following code snippet demonstrates how to configure an MCP client using the Safe MCP Server:
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
The server supports advanced configuration options, including the ability to modify the base API URL for testing and development purposes.
graph TD
A[Safe Transaction API URL] --> B[Configuration]
B --> C[Customize Environment Variables]
style A fill:#f3e5f5
style B fill:#e1f5fe
style C fill:#e8f5e8
To modify the base API URL, you can use environment variables:
SAFE_API_URL=https://safe-transaction-goerli.safe.global/api/v1 npm start
A: Yes, it supports both environments. You can switch the environment by setting the SAFE_API_URL
variable.
A: The default limit for querying transactions is 100. Custom limits can be applied by modifying the request parameters.
A: Yes, we implement strict API key validation and rate limiting to ensure secure interactions.
A: Absolutely, it supports integrating multiple AI clients seamlessly via the MCP protocol.
A: You can customize this by modifying the relevant code or using third-party solutions that integrate with the Safe API.
Contributions are welcome! If you’d like to contribute to the development of this server, please follow the guidelines available in our repository. Contributions help improve the overall functionality and usability of the MCP protocol for AI applications.
To contribute:
Explore more about Model Context Protocol and its ecosystem by visiting the official documentation and community forums. Join us in building a robust, interoperable platform for AI applications!
By leveraging the Safe MCP Server, developers can enhance their AI applications with secure, reliable interactions with smart contracts. This server is a cornerstone of the MCP protocol, ensuring that AI tools can seamlessly integrate with various data sources and tools.
This documentation provides comprehensive guidance on everything from installation to advanced configurations, enabling developers to harness the full potential of the Safe MCP Server for their AI application needs.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica