EM

edanyal/mcp-client

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

30 stars 3 forks 품질 54 트렌드 11

Typescript mcp 클라이언트 라이브러리.

개요

LLM Agent의 Model Context Protocol (MCP) 클라이언트의 TypeScript 구현. - MCP 사양의 전체 구현 - stdio 및 HTTP + SSE 운송 모두 지원 - 내장 MCP 서버 프로세스 관리 - Claude의 기본 도구와 통합 - Type-safe API - 이벤트 기반 아키텍처 - 모든 MCP 운영 지원 : - 자원 - 도구 - Prompts - 샘플링 MCP 클라이언트를 사용하는 가장 일반적인 방법은 npx를 통해 표준 MCP 서버입니다. 설정파일 만들기 (mcp-config.

개요(AI 번역)

LLM Agent의 Model Context Protocol (MCP) 클라이언트의 TypeScript 구현.

설치

특징

  • MCP 사양의 전체 구현
  • stdio와 HTTP+SSE 수송 둘 다를 위한 지원
  • 내장 MCP 서버 프로세스 관리
  • Claude의 기본 도구와 통합
  • 유형 안전 API
  • 이벤트 기반 건축
  • Promise 기반 async/await API
  • 모든 MCP 운영 지원:
  • 자료
  • 도구
  • 프롬츠
  • 샘플링

사용법

MCP 서버 사용

MCP 클라이언트를 사용하는 가장 일반적인 방법은 npx를 통해 표준 MCP 서버입니다. 구성 파일 생성 (mcp-config.json):

그런 다음 MCPConnectionManager를 사용하여 서버에 연결하십시오.

Claude와 통합

클라이언트는 Claude의 기본 도구 호출과 완벽하게 작동하도록 설계되었습니다.

저수준 사용법

더 많은 컨트롤이 필요한 경우, 직접 클라이언트를 사용할 수 있습니다.

유효한 MCP 서버

npx를 통해 제공되는 일반적인 MPC 서버:

  • @modelcontextprotocol/server-memory - 지식 그래프 작업
  • @modelcontextprotocol/server-filesystem - 파일 시스템 운영
  • @modelcontextprotocol/server-brave-search - 웹 검색 기능

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.

README

원문 README의 일부입니다. 원문 보기.

MCP Client

A TypeScript implementation of a Model Context Protocol (MCP) client for LLM agents.

Installation

npm install mcp-client

Features

  • Full implementation of the MCP specification
  • Support for both stdio and HTTP+SSE transports
  • Built-in MCP server process management
  • Integration with Claude’s native tool calling
  • Type-safe API
  • Event-based architecture
  • Promise-based async/await API
  • Support for all MCP operations:
    • Resources
    • Tools
    • Prompts
    • Sampling

Usage

Using with MCP Servers

The most common way to use MCP Client is with standard MCP servers via npx. Create a configuration file (mcp-config.json):

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-memory"
      ]
    },
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/path/to/allowed/directory"
      ]
    },
    "brave-search": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-brave-search"
      ],
      "env": {
        "BRAVE_API_KEY": "your-api-key"
      }
    }
  }
}

Then use the MCPConnectionManager to connect to your servers:

import { MCPConnectionManager } from 'mcp-client';

const manager = new MCPConnectionManager();
await manager.initialize('./mcp-config.json');

// Get clients for specific servers
const memoryClient = manager.getClient('memory');
const fsClient = manager.getClient('filesystem');

// Use tools from the servers
const memoryTools = await memoryClient?.listTools();
const fsTools = await fsClient?.listTools();

// Clean up when done
await manager.cleanup();

Integration with Claude

The client is designed to work seamlessly with Claude’s native tool calling:

import { Anthropic } from '@anthropic-ai/sdk';
import { MCPConnectionManager } from 'mcp-client';

// Initialize Claude and MCP
const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
const manager = new MCPConnectionManager();
await manager.initialize('./mcp-config.json');

// Get a client
const memoryClient = manager.getClient('memory');
const tools = await memoryClient?.listTools();

// Use with Claude
const response = await anthropic.messages.create({
  model: 'claude-3-sonnet-20240229',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'your prompt' }],
  tools: tools?.map(tool => ({
    name: tool.name,
    description: tool.description || '',
    parameters: tool.inputSchema
  }))
});

// Handle tool calls
if (!response.content[0].text && response.content[0].type === 'tool_call') {
  const toolCall = response.content[0].tool_calls[0];
  const result = await memoryClient?.callTool(
    toolCall.name,
    toolCall.parameters
  );
  // Send result back to Claude...
}

Low-level Usage

If you need more control, you can use the client directly:

GitHub에서 전체 README 보기

설치

npx -y @modelcontextprotocol/server-memory
MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →

설정

{ "mcpServers": { "memory": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-memory" ] }, "filesystem": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/directory" ] }, "brave-search": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-brave-search" ], "env": { "BRAVE_API_KEY": "your-api-key" } } } }