MCP-ODOS:去中心化交易所的模型上下文协议服务器
该项目实现了一个模型上下文协议 (MCP) 服务器,用于与去中心化交易所 (DEX) 进行交互。它允许兼容 MCP 的客户端(例如 AI 助手、IDE 扩展或自定义应用程序)访问诸如获取掉期报价和执行掉期交易等功能。
该服务器是使用 TypeScript 和fastmcp
构建的。
功能(MCP 工具)
服务器公开了 MCP 客户端可以利用的以下工具:
ODOS_GET_QUOTE
:获取掉期报价。- 参数:
chainId
(数字)、sellToken
(字符串)、buyToken
(字符串)、sellAmount
(字符串)
- 参数:
ODOS_EXECUTE_SWAP
:执行交换。- 参数:
chainId
(数字)、sellToken
(字符串)、buyToken
(字符串)、sellAmount
(字符串)、quote
(字符串)、walletProvider
(字符串)
- 参数:
参数细分
chainId
:DEX 的链 ID。sellToken
:您想要出售的代币。buyToken
:您想要购买的代币。sellAmount
:您想要出售的代币数量。quote
:您从get-quote
服务获得的报价。walletProvider
:您想要使用的钱包提供商。
先决条件
- Node.js(建议使用 v18 或更高版本)
- pnpm(参见https://pnpm.io/installation )
安装
有几种使用mcp-odos
方法:
1. 使用pnpm dlx
(推荐用于大多数 MCP 客户端设置):
您可以直接使用pnpm dlx
运行服务器,无需全局安装。这通常是与 MCP 客户端集成的最简单方法。请参阅“使用 MCP 客户端运行服务器”部分的示例。( pnpm dlx
是 pnpm 中与npx
等效的版本)
2. 从 npm 进行全局安装(通过 pnpm):
全局安装该软件包以使mcp-odos
命令在整个系统范围内可用:
3.从源代码构建(用于开发或自定义修改):
- 克隆存储库:
- 安装依赖项:
- **构建服务器:**这会将
dist
目录中的 TypeScript 代码编译为 JavaScript。prepare
脚本还运行pnpm run build
,因此如果您克隆并运行pnpm install
则会在安装时构建依赖项。
配置(环境变量)
此 MCP 服务器可能需要运行它的 MCP 客户端设置某些环境变量。这些变量通常在客户端的 MCP 服务器定义中配置(例如,Cursor 的mcp.json
文件,或其他客户端的类似文件)。
- 钱包提供商或 API 密钥的任何必要环境变量。
使用 MCP 客户端运行服务器
MCP 客户端(例如 AI 助手、IDE 扩展等)会将此服务器作为后台进程运行。您需要配置客户端以告知它如何启动服务器。
以下是 MCP 客户端可能使用的配置示例代码片段(例如,在mcp_servers.json
或类似的配置文件中)。此示例展示了如何通过pnpm dlx
使用已发布的 npm 包来运行服务器。
如果全局安装,则替代方案:
如果您已经全局安装了mcp-odos
( pnpm add -g mcp-odos
),您可以简化command
和args
:
command
:要运行的可执行文件。- 对于
pnpm dlx
:"pnpm"
(以"dlx"
作为第一个参数) - 全局安装:
"mcp-odos"
- 对于
args
:传递给命令的参数数组。- 对于
pnpm dlx
:["dlx", "mcp-odos"]
- 对于全局安装:
[]
- 对于
env
:一个包含服务器进程启动时要设置的环境变量的对象。您可以在此处提供任何必要的环境变量。workingDirectory
:通过pnpm dlx
或全局安装使用已发布的包时通常不需要,因为包本身应该能够正确处理其自身的路径。如果您从源代码(node dist/index.js
)运行,则将workingDirectory
设置为项目根目录非常重要。
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
模型上下文协议服务器,使人工智能助手和应用程序能够与去中心化交易所(DEX)进行交互,从而允许用户获取代币交换的报价并执行交换交易。
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol server that enables AI agents to interact with 30+ Ethereum-compatible blockchain networks, providing services like token transfers, contract interactions, and ENS resolution through a unified interface.Last updated -28230252TypeScriptMIT License
- -securityFlicense-qualityA comprehensive Model Context Protocol server implementation that enables AI assistants to interact with file systems, databases, GitHub repositories, web resources, and system tools while maintaining security and control.Last updated -16TypeScript
- AsecurityAlicenseAqualityA server that allows AI models to interact with cryptocurrency exchange APIs through the Model Context Protocol, providing access to over 100 exchanges and their trading capabilities.Last updated -2047219TypeScriptMIT License
Hashkey MCP Serverofficial
-security-license-qualityA Model Context Protocol server that provides onchain tools for AI applications to interact with the Hashkey Network, enabling cryptocurrency transfers, smart contract deployment, and blockchain interactions.Last updated -TypeScriptMIT License