Bedrock Prompts MCP Server

Bedrock Prompts MCP Server

Enables management and invocation of AWS Bedrock managed prompts with support for variable substitution, streaming responses, batch processing, and multiple AI models including Claude, Titan, Llama, and Mistral.

Category
访问服务器

README

Bedrock Prompts MCP Server

An MCP (Model Context Protocol) server for managing and invoking AWS Bedrock managed prompts.

Features

  • List Prompts: Browse all available Bedrock managed prompts
  • Get Prompt Details: View complete prompt configuration including templates, variables, and model settings
  • Invoke Prompts: Execute prompts with variable substitution and get model responses
  • Batch Invocation: Run the same prompt multiple times with different inputs in parallel
  • Streaming Responses: Get real-time streaming output from prompts (for supported models)
  • Multi-Model Support: Works with Claude, Amazon Titan, Meta Llama, Mistral AI, Cohere, and AI21 models
  • Version Management: List and access different versions of prompts

Prerequisites

  • Python 3.10 or higher
  • AWS credentials configured (via AWS CLI, environment variables, or IAM role)
  • Access to AWS Bedrock service
  • Claude Desktop (for MCP integration)

Installation

Option 1: Local Development

# Clone or download the files
cd /path/to/bedrock-prompts-mcp

# Install dependencies
pip install -r requirements.txt

# Test the server
python bedrock_prompts_mcp_server.py

Option 2: Install as Package

pip install -e .

AWS Configuration

Ensure your AWS credentials are configured. The server will use the default credential chain:

# Via AWS CLI
aws configure

# Or set environment variables
export AWS_ACCESS_KEY_ID=your_key
export AWS_SECRET_ACCESS_KEY=your_secret
export AWS_REGION=us-east-1

Optional environment variables:

  • AWS_REGION: AWS region for Bedrock (default: us-east-1)
  • BEDROCK_TENANT_ID: Optional tenant identifier

Claude Desktop Configuration

Add this to your Claude Desktop config file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "bedrock-prompts": {
      "command": "python",
      "args": ["/absolute/path/to/bedrock_prompts_mcp_server.py"],
      "env": {
        "AWS_REGION": "us-east-1"
      }
    }
  }
}

If you installed as a package:

{
  "mcpServers": {
    "bedrock-prompts": {
      "command": "bedrock-prompts-mcp",
      "env": {
        "AWS_REGION": "us-east-1"
      }
    }
  }
}

Usage in Claude Desktop

Once configured, you can use natural language to interact with your Bedrock prompts:

Examples

List available prompts:

Show me all my Bedrock prompts

Get prompt details:

Get the details for prompt VSWZVOISYG

Invoke a prompt:

Invoke prompt VSWZVOISYG with the question "How do you feel about the economy?"

Generate multiple responses:

Use prompt VSWZVOISYG to generate 5 different survey responses to "How do you feel about the economy?"

Batch invoke with different inputs:

Batch invoke prompt VSWZVOISYG with these questions:
1. "How do you feel about the economy?"
2. "What are your hiring plans?"
3. "How do you view inflation?"

Stream a long response:

Stream the response from prompt VSWZVOISYG with streaming enabled

Available Tools

1. list_bedrock_prompts

Lists all available Bedrock managed prompts.

Parameters:

  • max_results (optional): Number of results (1-100, default: 20)
  • next_token (optional): Pagination token

2. get_bedrock_prompt_details

Gets detailed information about a specific prompt.

Parameters:

  • prompt_identifier (required): Prompt ID or ARN
  • prompt_version (optional): Specific version (default: DRAFT)

3. invoke_bedrock_prompt

Invokes a prompt with variables and returns the model's response.

Parameters:

  • prompt_identifier (required): Prompt ID or ARN
  • prompt_variables (optional): Dict of variable substitutions
  • prompt_version (optional): Specific version (default: DRAFT)

Example variables:

{
  "question": "How do you feel about the economy?",
  "context": "Survey for small business owners"
}

4. list_bedrock_prompt_versions

Lists all versions of a specific prompt.

Parameters:

  • prompt_identifier (required): Prompt ID or ARN
  • max_results (optional): Number of results (1-100, default: 20)

5. invoke_bedrock_prompt_stream

Invokes a prompt with streaming response for real-time output.

Parameters:

  • prompt_identifier (required): Prompt ID or ARN
  • prompt_variables (optional): Dict of variable substitutions
  • prompt_version (optional): Specific version (default: DRAFT)

Returns: Full completion text plus array of streamed chunks

6. batch_invoke_bedrock_prompt

Invokes a prompt multiple times with different variable sets in parallel.

Parameters:

  • prompt_identifier (required): Prompt ID or ARN
  • variable_sets (required): Array of variable dictionaries
  • prompt_version (optional): Specific version (default: DRAFT)
  • max_workers (optional): Parallel workers (1-10, default: 5)

Example variable_sets:

[
  {"question": "How do you feel about the economy?"},
  {"question": "What are your hiring plans?"},
  {"question": "How do you view inflation?"}
]

Returns: Aggregated results with success/failure counts and individual responses

Supported Model Types

The server automatically detects and formats requests for:

  • Anthropic Claude (claude-3, claude-3-5-sonnet, etc.)
  • Amazon Titan (titan-text-express, titan-text-lite)
  • Meta Llama (llama-2, llama-3, etc.)
  • Mistral AI (mistral-7b, mixtral-8x7b)
  • Cohere (command, command-light)
  • AI21 Labs (jurassic-2)

Each model type uses the appropriate request/response format automatically.

Troubleshooting

Server won't start

  • Check that AWS credentials are configured: aws sts get-caller-identity
  • Verify Python version: python --version (should be 3.10+)
  • Check logs in Claude Desktop: Help → Show Logs

"No credentials found" error

  • Run aws configure to set up credentials
  • Or use environment variables in the config file

Prompt invocation fails

  • Verify the prompt exists: List prompts first
  • Check that the model specified in the prompt is available in your region
  • Ensure you have permissions to invoke Bedrock models

Variable substitution not working

  • Check that variable names match exactly (case-sensitive)
  • The server supports both {{variable}} and {variable} syntax
  • View prompt details to see expected variable names

Development

Running Tests

# Test AWS connectivity
python bedrock_prompts_mcp_server.py

Adding New Features

The server is structured to make it easy to add new Bedrock operations:

  1. Add a new function in the main file
  2. Register it in list_tools()
  3. Handle it in call_tool()

Security Notes

  • Never commit AWS credentials to version control
  • Use IAM roles when possible (e.g., on EC2 instances)
  • Follow least-privilege principles for IAM permissions
  • The server runs locally and doesn't expose network endpoints

Required IAM Permissions

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "bedrock:ListPrompts",
        "bedrock:GetPrompt",
        "bedrock:ListPromptVersions",
        "bedrock:InvokeModel"
      ],
      "Resource": "*"
    }
  ]
}

License

MIT

Support

For issues or questions:

  • Check the troubleshooting section
  • Review AWS Bedrock documentation
  • Check MCP documentation at https://modelcontextprotocol.io

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选