1.0.1 • Published 6 months ago

aws-kb v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

aws-kb

A Model Context Protocol (MCP) server that enables querying AWS Bedrock Knowledge Bases. This server allows AI assistants to access and query your AWS Bedrock Knowledge Base through a standardized interface.

npm version License: MIT

Features

  • Query AWS Bedrock Knowledge Bases using natural language
  • Support for context-aware queries
  • Configurable response generation parameters
  • Easy integration with MCP-compatible AI assistants

Installation

# Install globally
npm install -g aws-kb

# Or install as a project dependency
npm install aws-kb

Prerequisites

  • Node.js >= 18.0.0
  • An AWS account with Bedrock access
  • A configured AWS Bedrock Knowledge Base
  • AWS credentials with appropriate permissions

Configuration

The server requires the following environment variables to be set:

VariableDescription
AWS_ACCESS_KEY_IDYour AWS access key
AWS_SECRET_ACCESS_KEYYour AWS secret key
AWS_REGIONThe AWS region where your Knowledge Base is located
AWS_KNOWLEDGE_BASE_IDThe ID of your Knowledge Base
AWS_INFERENCE_PROFILE_ARNThe ARN of the inference profile to use

You can set these environment variables in your shell:

export AWS_ACCESS_KEY_ID="your_access_key"
export AWS_SECRET_ACCESS_KEY="your_secret_key"
export AWS_REGION="your_region"
export AWS_KNOWLEDGE_BASE_ID="your_kb_id"
export AWS_INFERENCE_PROFILE_ARN="your_profile_arn"

Or create a .env file in your project:

AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=your_region
AWS_KNOWLEDGE_BASE_ID=your_kb_id
AWS_INFERENCE_PROFILE_ARN=your_profile_arn

Usage

As a Command Line Tool

When installed globally, you can run the server directly:

aws-kb

As a Module

import { AWSKnowledgeBaseServer } from 'aws-kb';

const server = new AWSKnowledgeBaseServer();
server.run().catch(console.error);

Using with Claude

  1. Add the server configuration to your Claude settings:
{
  "mcpServers": {
    "aws-kb": {
      "command": "aws-kb",
      "env": {
        "AWS_ACCESS_KEY_ID": "your_access_key",
        "AWS_SECRET_ACCESS_KEY": "your_secret_key",
        "AWS_REGION": "your_region",
        "AWS_KNOWLEDGE_BASE_ID": "your_kb_id",
        "AWS_INFERENCE_PROFILE_ARN": "your_profile_arn"
      }
    }
  }
}
  1. The server provides a query_knowledge_base tool that accepts the following parameters:
ParameterTypeRequiredDescription
querystringYesThe question or query to ask
contextstringNoAdditional context to help inform the query
temperaturenumberNoTemperature parameter for response generation (0.0 to 1.0)

Example Usage

// Example query to send to the server
const query = {
  jsonrpc: '2.0',
  id: 1,
  method: 'callTool',
  params: {
    name: 'query_knowledge_base',
    arguments: {
      query: 'What is AWS Bedrock?',
      context: 'I am new to AWS services',
      temperature: 0.7
    }
  }
};

// Send the query to the server
server.stdin.write(JSON.stringify(query) + '\n');

For more examples, check out the examples directory.

Development

To build from source:

git clone https://github.com/assaads/aws-kb.git
cd aws-kb
npm install
npm run build

Testing

You can use the MCP Inspector to test the server locally:

npm run inspector

Scripts

  • npm run build - Build the TypeScript source
  • npm run watch - Watch for changes and rebuild
  • npm start - Run the server
  • npm run inspector - Run the MCP inspector for testing

API Reference

Server Configuration

The server can be configured through environment variables and constructor options:

interface ServerConfig {
  name?: string;
  version?: string;
  capabilities?: {
    tools?: Record<string, unknown>;
  };
}

const server = new AWSKnowledgeBaseServer({
  name: 'custom-name',
  version: '1.0.0'
});

Query Parameters

interface QueryParams {
  query: string;
  context?: string;
  temperature?: number;
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Related Projects