[!TIP] 跳过设置,直接使用托管服务: 使用 Metorial 最快速、最简单且最可靠的方式是注册我们的 托管平台。
➡️ 开始使用(免费)
Metorial 使AI代理开发者能够轻松地通过模型上下文协议(MCP),将他们的模型连接到广泛的API、数据源和工具。 Metorial 抽象了 MCP 的复杂性,并为开发者提供了一个简单的统一接口,包括强大的SDK、详细的监控以及高度可定制的平台。
Metorial 目前提供了以下语言的SDK:
如果您想构建自定义集成,请查看我们的 API 文档,了解如何直接使用 Metorial API 的详细信息。
Metorial 平台 是驱动 Metorial 背后引擎的代码。它是开源的,可以自行托管。您可以使用它来运行自己的 Metorial 实例,由此仓库中的 MCP 服务器提供支持。
最简单的方法是从 .run() 方法开始,该方法会自动处理会话管理和对话循环:
import { Metorial } from 'metorial';
import OpenAI from 'openai';
let metorial = new Metorial({ apiKey: 'your-metorial-api-key' });
let openai = new OpenAI({ apiKey: 'your-openai-api-key' });
let result = await metorial.run({
message: '扫描我的Slack消息以查找会议并将它们添加到我的Google日历中。',
serverDeployments: ['google-calendar-server', 'slack-server'],
model: 'gpt-4o',
client: openai,
maxSteps: 10 // 可选:限制对话步骤
});
console.log(`响应(完成于 ${result.steps} 步骤):`);
console.log(result.text);
import asyncio
from metorial import Metorial
from openai import AsyncOpenAI
async def main():
metorial = Metorial(api_key="your-metorial-api-key")
openai = AsyncOpenAI(api_key="your-openai-api-key")
response = await metorial.run(
message="搜索Hackernews上的最新AI讨论。",
server_deployments=["hacker-news-server-deployment"],
client=openai,
model="gpt-4o",
max_steps=25 # 可选
)
print("响应:", response.text)
asyncio.run(main())
当与需要用户身份验证的服务(如Google日历、Slack等)一起工作时,Metorial 提供了OAuth会话管理来处理身份验证流程:
import { Metorial } from 'metorial';
import Anthropic from '@anthropic-ai/sdk';
let metorial = new Metorial({ apiKey: 'your-metorial-api-key' });
let anthropic = new Anthropic({ apiKey: 'your-anthropic-api-key' });
// 为需要用户身份验证的服务创建OAuth会话
let [googleCalOAuthSession, slackOAuthSession] = await Promise.all([
metorial.oauth.sessions.create({
serverDeploymentId: 'your-google-calendar-server-deployment-id'
}),
metorial.oauth.sessions.create({
serverDeploymentId: 'your-slack-server-deployment-id'
})
]);
// 给用户提供OAuth URL进行身份验证
console.log('OAuth URL用于用户身份验证:');
console.log(` Google日历:${googleCalOAuthSession.url}`);
console.log(` Slack:${slackOAuthSession.url}`);
// 等待用户完成OAuth流程
await metorial.oauth.waitForCompletion([googleCalOAuthSession, slackOAuthSession]);
console.log('OAuth会话已完成!');
// 现在使用已认证的会话进行您的运行
let result = await metorial.run({
message: `在Slack中查找潜在合作伙伴的提及。使用Exa研究他们的背景、公司和电子邮件。安排一个30分钟的介绍电话,时间为2025年12月13日SF时间的空闲时段,并发送给我日历链接。无需确认即可进行操作。`,
serverDeployments: [
{
serverDeploymentId: 'your-google-calendar-server-deployment-id',
oauthSessionId: googleCalOAuthSession.id
},
{
serverDeploymentId: 'your-slack-server-deployment-id',
oauthSessionId: slackOAuthSession.id
},
{
serverDeploymentId: 'your-exa-server-deployment-id' // Exa不需要OAuth
}
],
client: anthropic,
model: 'claude-3-5-sonnet-20241022'
});
console.log(result.text);
import asyncio
import os
from metorial import Metorial
from anthropic import AsyncAnthropic
async def main():
metorial = Metorial(api_key=os.getenv("METORIAL_API_KEY"))
anthropic = AsyncAnthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
# 为已认证的服务创建OAuth会话
google_cal_deployment_id = os.getenv("GOOGLE_CALENDAR_DEPLOYMENT_ID")
print("🔗 创建OAuth会话...")
oauth_session = metorial.oauth.sessions.create(
server_deployment_id=google_cal_deployment_id
)
print("OAuth URL用于用户身份验证:")
print(f" Google日历:{oauth_session.url}")
print("\n⏳ 等待OAuth完成...")
await metorial.oauth.wait_for_completion([oauth_session])
print("✅ OAuth会话已完成!")
# 使用混合认证的多个服务器部署
hackernews_deployment_id = os.getenv("HACKERNEWS_DEPLOYMENT_ID")
result = await metorial.run(
message="""使用可用工具搜索Hackernews上的最新AI讨论。然后使用Google日历工具为我@email.address安排明天下午2点的AI趋势讨论事件。""",
server_deployments=[
{ "serverDeploymentId": google_cal_deployment_id, "oauthSessionId": oauth_session.id },
{ "serverDeploymentId": hackernews_deployment_id },
],
client=anthropic,
model="claude-sonnet-4-20250514",
max_tokens=4096,
max_steps=25,
)
print(result.text)
asyncio.run(main())
metorial.oauth.sessions.create()metorial.oauth.waitForCompletion() 等待用户完成OAuth流程serverDeployments 时传递 oauthSessionId查看 examples/ 目录获取更全面的示例:
https://github.com/metorial/metorial-node/tree/main/examples/typescript-openai-run/ - 简单的.run()方法示例https://github.com/metorial/metorial-node/tree/main/examples/typescript-openai/ - 手动OpenAI集成https://github.com/metorial/metorial-node/tree/main/examples/typescript-anthropic/ - Anthropic集成https://github.com/metorial/metorial-node/tree/main/examples/typescript-ai-sdk/ - AI SDK集成跨不同AI提供商使用相同的工具
| 提供商 | 模型示例 | 客户端所需 |
|---|---|---|
| OpenAI | gpt-4o, gpt-4, gpt-3.5-turbo | openaiClient |
| Anthropic | claude-3-5-sonnet-20241022, claude-3-haiku-20240307 | anthropicClient |
gemini-pro, gemini-1.5-pro, gemini-flash | googleClient | |
| DeepSeek | deepseek-chat, deepseek-coder | deepseekClient |
| Mistral | mistral-large-latest, mistral-small-latest | mistralClient |
| XAI | grok-beta, grok-vision-beta | xaiClient |
| TogetherAI | meta-llama/Llama-2-70b-chat-hf, NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO | togetheraiClient |
MCP 是一种强大的标准,用于将AI模型连接到外部数据和工具,但它专注于使AI客户端(如Claude Desktop或Cursor)能够连接到工具和数据源。 Metorial 在此基础上构建,但使其成为开发人员的一行代码,以便他们可以将AI应用程序连接到任何API、数据源或工具。 因此,我们使开发人员能够创建能够以可靠、简单和安全的方式与其他系统交互的代理AI应用程序。
Metorial 旨在让开发人员非常容易地将他们的AI应用程序连接到外部数据和工具。由 Model Context Protocol (MCP) 提供支持,Metorial 是基于标准构建的。
Metorial 服务器索引 已经包含了超过5000个 MCP 服务器。找到并使用适合您AI应用程序的 MCP 服务器非常简单。一切都可搜索并且整齐地组织起来,所以您可以找到适合您使用场景的正确服务器。
https://github.com/user-attachments/assets/a171030e-0159-4ce2-9e92-f4fb3f7bfdc6
直接在 Metorial 仪表板中测试和探索 MCP 服务器。内置的 MCP 探索器允许您在不离开仪表板的情况下使用任何 MCP 服务器。这使得在编写任何代码之前测试和调试您的集成变得容易。
https://github.com/user-attachments/assets/eeb73085-e1d6-4745-988a-385694d26500
每个 MCP 会话都会被记录下来,并可以在 Metorial 仪表板中进行审查。这使您能够监控并发现您的集成中的问题。而且更好的是,如果发生错误,Metorial 会检测到并提供详细的错误报告,这样您可以快速解决问题。
https://github.com/user-attachments/assets/c676411e-25b6-442a-af22-c8d99e2be25b
Metorial 是从头开始为开发人员打造的。以下是使 Metorial 成为开发人员优秀选择的一些关键特性:
Metorial 目录在 Apache License 2.0 下发布。
<div align="center"> <sub>由 <a href="https://metorial.com">Metorial</a> 制作 ❤️</sub> </div>