ifly火花剂mcp
这是一个使用MCP服务器调用科大讯飞SparkAgent平台任务链的简单示例。
用法
本地调试
使用stdio(默认)或SSE传输启动服务器:
# Using stdio transport (default)
uv run ifly-spark-agent-mcp
# Using SSE transport on custom port
uv run ifly-spark-agent-mcp --transport sse --port 8000默认情况下,服务器会公开一个名为“upload_file”的工具,该工具接受一个必需的参数:
file:上传文件的路径
MCP客户端示例
使用MCP客户端,您可以使用STDIO传输这样的工具:
import asyncio
from mcp.client.session import ClientSession
from mcp.client.stdio import StdioServerParameters, stdio_client
async def main():
async with stdio_client(
StdioServerParameters(command="uv", args=["run", "ifly-spark-agent-mcp"])
) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
# List available tools
tools = await session.list_tools()
print(tools)
# Call the upload_file tool
result = await session.call_tool("upload_file", {"file": "/path/to/file"})
print(result)
asyncio.run(main())
与MCP客户端一起使用
在Claude上使用
要添加持久客户端,请将以下内容添加到您的 claude_desktop_config.json 或 mcp.json 文件:
1.使用紫外线
{
"mcpServers": {
"ifly-spark-agent-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/to/ifly-spark-agent-mcp",
"run",
"ifly-spark-agent-mcp"
],
"env": {
"IFLY_SPARK_AGENT_BASE_URL": "xxxx",
"IFLY_SPARK_AGENT_APP_ID": "xxxx",
"IFLY_SPARK_AGENT_APP_SECRET": "xxxx"
}
}
}
}2.在github仓库中使用uvx
{
"mcpServers": {
"ifly-spark-agent-mcp": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/iflytek/ifly-spark-agent-mcp",
"ifly-spark-agent-mcp"
],
"env": {
"IFLY_SPARK_AGENT_BASE_URL": "xxxx",
"IFLY_SPARK_AGENT_APP_ID": "xxxx",
"IFLY_SPARK_AGENT_APP_SECRET": "xxxx"
}
}
}
}