统一的MCP编排器,通过单一端点连接AI代理到多个提供商(如Linear、Sentry等)。
bun install
import Pleiades from './src/main.js';
import type { PleiadesConfig } from './src/types.js';
// 配置提供商
const config: PleiadesConfig = {
name: 'pleiades', // 这将成为 `use_pleiades` 工具
baseUrl: 'http://localhost:8787',
providers: [
{
id: 'sentry',
mcpUrl: 'https://mcp.sentry.dev/mcp',
oauth: {
authUrl: 'https://mcp.sentry.dev/oauth/authorize',
tokenUrl: 'https://mcp.sentry.dev/oauth/token',
clientId: process.env.SENTRY_CLIENT_ID!,
clientSecret: process.env.SENTRY_CLIENT_SECRET!,
scopes: ['org:read', 'project:write']
}
},
{
id: 'linear',
mcpUrl: 'https://mcp.linear.app/mcp',
oauth: {
authUrl: 'https://linear.app/oauth/authorize',
tokenUrl: 'https://api.linear.app/oauth/token',
clientId: process.env.LINEAR_CLIENT_ID!,
clientSecret: process.env.LINEAR_CLIENT_SECRET!,
scopes: ['read', 'write']
}
},
...
],
store: yourTokenStore // 实现 TokenStore 接口
};
// 创建实例
const pleiades = new Plei
ades(config);
// 提供服务
Bun.serve({
port: 8787,
fetch: pleiades.fetch
});
提供商类型:
oauth 配置apiToken 进行简单的基于令牌的身份验证TokenStore 接口:
interface TokenStore {
getToken(tenantId: string, providerId: string, accountId?: string): Promise<Token | null>;
setToken(tenantId: string, providerId: string, accountId: string, token: Token): Promise<void>;
revokeToken(tenantId: string, providerId: string, accountId: string): Promise<void>;
getAccounts(tenantId: string, providerId: string): Promise<string[]>;
}
GET /mcp - AI代理的MCP端点GET /oauth/callback - OAuth回调处理器use_{providerId}bun run dev
当前支持Cloudflare Workers。OAuth需要一个数据库来存储令牌。 </中文翻译>