AshAgentMcp
Ash Agent的MCP(模型上下文协议)客户端集成。
此软件包使Ash代理能够连接到外部MCP服务器并使用其工具。 MCP工具对代理来说是常规工具,与本地工具无缝集成。
安装
添加 ash_agent_mcp 到中的依赖项列表 mix.exs:
def deps do
[
{:ash_agent_mcp, "~> 0.1.0"}
]
end用法
defmodule MyApp.DatabaseAgent do
use Ash.Resource,
domain: MyApp.Agents,
extensions: [AshAgent.Resource, AshAgentTools.Resource, AshAgentMcp.Resource]
agent do
client "anthropic:claude-sonnet-4-20250514"
instruction "You have access to database tools."
end
agent_mcp_servers do
server :neon do
url "https://mcp.neon.tech/sse"
auth {:bearer, {:env, "NEON_API_KEY"}}
end
end
end认证
MCP服务器可以配置承载令牌身份验证:
# From environment variable
auth {:bearer, {:env, "API_KEY"}}
# Literal value (not recommended for production)
auth {:bearer, "your-token"}
# No authentication
auth :none许可证
麻省理工学院
