JB

juspay/bedrock-mcp-connector

Developer toolsОфициальный

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

2 stars 6 forks Качество 40 Тренд 8

A connector to connect agentic models to MCP tools

Обзор

A TypeScript client for interacting with AWS Bedrock and MCP (Model Context Protocol) servers. - Seamless integration with AWS Bedrock's Converse API - Support for Claude and other Bedrock models - Connect to MCP servers to discover and use available tools - Register custom tool handlers - Event-based architecture for streaming responses - TypeScript support with full type definitions - Command-line interface for interactive usage - Modular design for easy integration into other projects The package supports both in-memory and Redis storage for conversation history: Tools are a powerful feature that allow the LLM to perform actions and access external data. This section provides detailed guidance on how to create and register tools effectively. The registerTool method takes four parameters: 1. : Each tool should do one thing well 2. : Use descriptive, action-oriented names (e.g., getCurrentTime, searchDatabase) 3.

README

Показан фрагмент оригинального README. Открыть оригинал.

Bedrock MCP Connector

A TypeScript client for interacting with AWS Bedrock and MCP (Model Context Protocol) servers.

Features

  • Seamless integration with AWS Bedrock’s Converse API
  • Support for Claude and other Bedrock models
  • Connect to MCP servers to discover and use available tools
  • Register custom tool handlers
  • Event-based architecture for streaming responses
  • TypeScript support with full type definitions
  • Command-line interface for interactive usage
  • Modular design for easy integration into other projects

Installation

npm install @juspay/bedrock-mcp-connector

Usage

Basic Usage

import { BedrockMCPClient, LogLevel } from "@juspay/bedrock-mcp-connector";

// Create a client
const client = new BedrockMCPClient({
  modelId: "anthropic.claude-3-sonnet-20240229-v1:0",
  region: "us-east-1",
  systemPrompt: "You are a helpful assistant.",
  mcpServerUrl: "http://localhost:5713/sse", // Optional
});

// Set the log level (optional)
// LogLevel.INFO - Default, shows important information
// LogLevel.DEBUG - Shows detailed debugging information
// LogLevel.WARN - Shows only warnings and errors
// LogLevel.ERROR - Shows only errors
// LogLevel.NONE - Suppresses all logs
client.setLogLevel(LogLevel.INFO);

// Connect to MCP server (if URL is provided)
if (client.mcpServerUrl) {
  await client.connect();
}

// Send a prompt
const response = await client.sendPrompt("What is the capital of France?");
console.log("Response:", response);

// Disconnect when done
if (client.isConnectedToMCP()) {
  await client.disconnect();
}

Using Redis for Persistent Storage

The package supports both in-memory and Redis storage for conversation history:

import { BedrockMCPClient } from "@juspay/bedrock-mcp-connector";

// Using Redis storage for persistent conversations
const client = new BedrockMCPClient({
  modelId: "anthropic.claude-3-sonnet-20240229-v1:0",
  region: "us-east-1",
  sessionId: "user-session-123", // Unique session identifier
  userId: "user-456", // Optional user identifier
  storage: {
    type: "redis",
    config: {
      host: "localhost",
      port: 6379,
      password: "your-redis-password", // Optional
      db: 0, // Redis database number
      keyPrefix: "bedrock-mcp:", // Key prefix for Redis keys
      ttl: 86400, // TTL in seconds (24 hours)
      connectionOptions: {
        connectTimeout: 5000,
        lazyConnect: true
      }
    }
  }
});

// Conversations are now persistent across client restarts
const response = await client.sendPrompt("Remember this: my favorite color is blue");
console.log("Response:", response);

// Later, in a new client instance with the same sessionId...
const newClient = new BedrockMCPClient({
  modelId: "anthropic.claude-3-sonnet-20240229-v1:0",
  region: "us-east-1",
  sessionId: "user-session-123", // Same session ID
  storage: { type: "redis", config: { /* same config */ } }
});
Открыть полный README на GitHub

Установка

npx @juspay/bedrock-mcp-connector
Новичок в MCP? Начните с руководства на mcpskill.org →