
vrknetha/aisdk-mcp-bridge
Developer tools이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기
Bridge Package는 Model Context Protocol (MCP) 서버와 AI SDK 도구와 원활한 통합을 가능하게 합니다. 다중 서버 유형, 실시간 통신 및 TypeScript를 지원합니다.
개요
Model Context Protocol (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 번역)
Model Context Protocol (MCP) 및 AI SDK 간의 원활한 통합을 가능하게 하는 교량 패키지는 MCP 서버와 AI 모델 간의 효율적인 통신 및 도구 실행을 가능하게 합니다.
특징
- MCP 서버와 AI SDK의 원활한 통합
- 다양한 MCP 서버 유형 지원 (Node.js, Python, UVX)
- 독립적 인 구성과 멀티 서버 지원
mcp.config.json을 통한 유연한 구성- TypeScript 지원
- Robust 오류 처리 및 로깅
- 툴 실행을 위한 Easy-to-use API
설치
빠른 시작
-
프로젝트 루트의
mcp.config.json파일 만들기: -
당신의 부호에 있는 교량을 수입하고 사용하십시오:
구성
mcp.config.json 파일은 여러 서버와 통신 모드를 지원합니다. 각 서버는 독립적으로 구성될 수 있습니다.
서버 구성 예제:
트위터 MCP 서버
Firecrawl 서버
SSE 서버
서버 모드
교량은 다른 커뮤니케이션 형태를 지원합니다:
1.stdio 모드 (기본값)
- 표준 입력/출력을 통한 직접 통신
- 간단한 통합 및 로컬 개발을위한 최고의
- 낮은 대기시간 및 최소 설정 필요
- 명세.
이 페이지는 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
- Create an
mcp.config.jsonfile 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"
}
}
}
}
- 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
{
설치
npx -y @enescinar/twitter-mcp설정
{
"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"
}
}
}
}