VA

vrknetha/aisdk-mcp-bridge

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

23 stars 2 forks 品質 64 トレンド 10MIT

ブリッジパッケージは、モデルコンテキストプロトコル(MCP)サーバーとAI SDKツール間のシームレスな統合を可能にします。 複数のサーバータイプ、リアルタイム通信、TypeScript に対応しています.

概要

モデルコンテキストプロトコル(MCP)とAI SDK間でシームレスな統合が可能なブリッジパッケージで、MCPサーバーとAIモデル間の効率的な通信とツールの実行が可能です。 - MCP サーバーとAI SDK 間のシームレスな統合 - さまざまな MCP サーバータイプ (Node.js、Python、UVX) のサポート - 独立した構成によるマルチサーバー サポート - mcp.config.json による柔軟な構成 - 完全なタイプ定義による TypeScript サポート - エラー処理とロギング - ツール実行のための使いやすい API 1. プロジェクトルートでmcp.config.jsonファイルを作成します。 2. あなたのコードの橋を輸入し、使用して下さい: mcp.config.json ファイルは複数のサーバーと通信モードをサポートしています。 各サーバーは独立して設定できます。 橋は異なった通信モードを支えます: - 標準的な入出力による直接通信 - 簡単な統合とローカル開発に最適です - 低レイテンシと最小限の設定が必要です 2.

概要(AI 翻訳)

モデルコンテキストプロトコル(MCP)とAI SDK間でシームレスな統合が可能なブリッジパッケージで、MCPサーバーとAIモデル間の効率的な通信とツールの実行が可能です。

##特徴

  • MCP サーバーとAI SDK 間のシームレスな統合
  • 各種MCPサーバータイプ(Node.js、Python、UVX)対応
  • 独立した構成の複数のサーバー サポート
  • [mcp.config.jsonによる柔軟な設定
  • フルタイプの定義によるTypeScriptサポート
  • 強力なエラー処理とロギング
  • ツール実行用の使いやすいAPI

インストール

クイックスタート

1。 プロジェクトルートで[mcp.config.jsonファイルを作成します。

  1. あなたのコードの橋を輸入し、使用して下さい:

設定

mcp.config.json は複数のサーバーと通信モードをサポートしています。 各サーバーは独立して設定できます。

サーバー構成例:

Twitter MCP サーバー

Firecrawl サーバー

##SSE サーバー

サーバーモード

橋は異なった通信モードを支えます:

1.stdio Mode (デフォルト)

  • 標準的な入出力による直接通信
  • 簡単な統合とローカル開発に最適な
  • 低レイテンシと最小限のセットアップが必要

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

AISDK MCP Bridge

A bridge package that enables seamless integration between the Model Context Protocol (MCP) and AI SDK, allowing for efficient communication and tool execution between MCP servers and AI models.

Features

  • Seamless integration between MCP servers and AI SDK
  • Support for various MCP server types (Node.js, Python, UVX)
  • Multi-server support with independent configuration
  • Flexible configuration through mcp.config.json
  • TypeScript support with full type definitions
  • Robust error handling and logging
  • Easy-to-use API for tool execution

Installation

npm install aisdk-mcp-bridge

Quick Start

  1. Create an mcp.config.json file in your project root:
{
  "mcpServers": {
    "twitter-mcp": {
      "command": "npx",
      "args": ["-y", "@enescinar/twitter-mcp"],
      "env": {
        "API_KEY": "your-twitter-api-key",
        "API_SECRET_KEY": "your-twitter-api-secret",
        "ACCESS_TOKEN": "your-twitter-access-token",
        "ACCESS_TOKEN_SECRET": "your-twitter-access-token-secret"
      }
    },
    "firecrawl": {
      "command": "npx",
      "args": ["-y", "mcp-server-firecrawl"],
      "env": {
        "FIRE_CRAWL_API_KEY": "your-firecrawl-api-key",
        "FIRE_CRAWL_API_URL": "https://api.firecrawl.com"
      }
    }
  }
}
  1. Import and use the bridge in your code:
import { generateText } from 'ai';
import { google } from '@ai-sdk/google';
import { getMcpTools, cleanupMcp, initializeMcp } from 'aisdk-mcp-bridge';
import dotenv from 'dotenv';
dotenv.config();

async function main() {
  try {
    // Initialize MCP
    await initializeMcp({ debug: true });

    // Get tools from all servers
    const allTools = await getMcpTools({ debug: true });

    // Or get tools from a specific server
    const twitterTools = await getMcpTools({
      debug: true,
      serverName: 'twitter-mcp',
    });

    // Use tools with AI SDK
    const result = await generateText({
      model: google('gemini-1.5-pro'),
      messages: [
        {
          role: 'system',
          content:
            'You are an AI assistant that uses various tools to help users.',
        },
        {
          role: 'user',
          content: 'Your task description here',
        },
      ],
      tools: twitterTools, // or allTools for all available tools
    });

    console.log('Result:', result.text);
  } finally {
    // Clean up resources
    await cleanupMcp();
  }
}

main().catch(error => {
  console.error('Error:', error);
  process.exit(1);
});

Configuration

The mcp.config.json file supports multiple servers and communication modes. Each server can be configured independently.

Server Configuration Examples:

Twitter MCP Server

{
GitHub で README 全文を見る

インストール

npx -y @enescinar/twitter-mcp
MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

{ "mcpServers": { "twitter-mcp": { "command": "npx", "args": ["-y", "@enescinar/twitter-mcp"], "env": { "API_KEY": "your-twitter-api-key", "API_SECRET_KEY": "your-twitter-api-secret", "ACCESS_TOKEN": "your-twitter-access-token", "ACCESS_TOKEN_SECRET": "your-twitter-access-token-secret" } }, "firecrawl": { "command": "npx", "args": ["-y", "mcp-server-firecrawl"], "env": { "FIRE_CRAWL_API_KEY": "your-firecrawl-api-key", "FIRE_CRAWL_API_URL": "https://api.firecrawl.com" } } } }