This is a simple MCP (Model Context Protocol) server that provides a notes API. It demonstrates how to create an MCP server with resources and tools that can be used by AI assistants and other MCP clients.
- List all available notes
- Read a specific note by ID
- Create new notes
- Make sure you have Python 3.10+ installed
- Create a virtual environment:
python -m venv venv - Activate the virtual environment:
# On macOS/Linux source venv/bin/activate # On Windows venv\Scripts\activate - Install the required packages:
pip install mcp httpx httpx-sse boto3
You can run the MCP server using the HTTP with Server-Sent Events (SSE) transport protocol:
python notes_server.py
The server will start on http://localhost:8080 with the SSE endpoint at /sse.
A test client implementation is provided to demonstrate how to interact with the MCP server:
python test_client.py
This client will:
- Connect to the MCP server
- List available tools
- Get the list of notes
- Read a specific note
- Create a new note
- Verify the new note was created
This project includes examples of integrating the MCP server with Amazon Bedrock:
This example demonstrates how to:
- Connect to the MCP server
- Retrieve all notes
- Pass the notes as context to a Bedrock model
- Get a response from the model
To run:
python bedrock_integration.py
This more advanced example demonstrates how to:
- Define MCP tools as Bedrock tools
- Let the model decide when to call tools
- Execute MCP tool calls based on the model's decisions
- Return tool results to the model
- Get the final response
To run:
python bedrock_tool_calling.py
The server is implemented using the FastMCP class from the MCP package. It provides:
- A resource endpoint at
resource://notesthat returns a list of all note IDs - A
ReadNotetool that reads a specific note by ID - A
CreateNotetool that creates a new note with a given ID and content
For more information about the Bedrock integration, see the bedrock_readme.md file.
If you encounter issues:
-
406 Not Acceptable Error: This occurs when the client doesn't accept the correct content type. Make sure your client accepts
text/event-streamfor SSE transport. -
Connection Issues: Check that the server is running on the expected port and address.
-
Response Parsing Errors: The MCP protocol returns structured objects. Make sure your client correctly handles the response structure:
session.list_tools()returns aListToolsResultobject with atoolsattributesession.read_resource()returns aReadResourceResultobject with acontentsattributesession.call_tool()returns aCallToolResultobject with acontentattribute
-
AWS Credentials: For Bedrock integration, ensure your AWS credentials are correctly configured and you have access to the specified Bedrock model.
-
Debug Mode: Enable debug mode and set the log level to DEBUG in the server for more detailed logs:
app = FastMCP( name="NotesServer", debug=True, log_level="DEBUG" )
notes_server.py: The MCP server implementation using SSE transporttest_client.py: Client that connects to the server using SSE transportbedrock_integration.py: Example of integrating MCP with Amazon Bedrockbedrock_tool_calling.py: Example of using Bedrock's tool calling with MCPbedrock_readme.md: Additional documentation for Bedrock integrationREADME.md: This file