
Python MCP Server Examples
A collection of Python-based Model Context Protocol servers that extend AI assistant capabilities with tools for calculations, AWS services (S3 and RDS), and PostgreSQL database operations.
README
MCP Sample
A Python implementation of Model Context Protocol (MCP) servers for extending AI assistant capabilities.
Overview
This project provides sample MCP servers that can be used with Amazon Q or other MCP-compatible AI assistants. The servers implement various functionalities:
- Calculator Server: Performs basic arithmetic operations
- RDS Server: Interacts with Amazon RDS instances
- S3 Server: Manages Amazon S3 buckets and objects
- PostgreSQL Server: Connects to PostgreSQL databases and executes queries
These servers demonstrate how to build MCP servers in Python using the FastMCP framework, which provides a high-level, Pythonic interface for implementing the Model Context Protocol.
Prerequisites
- Python 3.12+
- FastMCP library
- uv (recommended Python package manager for FastMCP)
- AWS credentials configured for RDS and S3 operations (for the respective servers)
- An MCP-compatible AI assistant (like Amazon Q)
Installation
Clone the repository and install the dependencies:
git clone <repository-url>
cd sample-building-mcp-servers-with-python
We recommend using uv to install dependencies as it's faster and more reliable than pip:
# Install uv if you don't have it
curl -sSf https://install.python-poetry.org | python3 -
# Install dependencies with uv
uv pip install -r requirements.txt
Alternatively, you can use pip:
pip install -r requirements.txt
Usage
Run each server independently:
# Run the calculator server
python src/calculator_server.py
# Run the RDS server
python src/rds_server.py
# Run the S3 server
python src/s3_server.py
# Run the PostgreSQL server (requires a connection string)
python src/postgresql_server.py "postgresql://username:password@hostname:port/database"
Integration with Amazon Q CLI
To integrate these MCP servers with Amazon Q CLI or other MCP-compatible clients, add a configuration like this to your .amazon-q.json
file:
{
"mcpServers": {
"calculator": {
"command": "python /path/to/sample-building-mcp-servers-with-python/src/calculator_server.py",
"args": []
},
"s3": {
"command": "python /path/to/sample-building-mcp-servers-with-python/src/s3_server.py",
"args": []
},
"rds": {
"command": "python /path/to/sample-building-mcp-servers-with-python/src/rds_server.py",
"args": []
},
"postgres": {
"command": "python /path/to/sample-building-mcp-servers-with-python/src/postgresql_server.py",
"args": ["postgresql://username:password@hostname:port/database"]
}
}
}
Replace /path/to/sample-building-mcp-servers-with-python/
with the actual path to your project. Once configured, Amazon Q will be able to use these servers to extend its capabilities.
Server Descriptions
Calculator Server
Provides basic arithmetic operations like addition, subtraction, multiplication, and division.
RDS Server
Lists and manages Amazon RDS instances in specified regions.
S3 Server
Manages S3 buckets and objects, including listing buckets by region.
PostgreSQL Server
Connects to PostgreSQL databases and executes read-only queries, lists tables, and provides schema information.
Understanding the Code
Each server follows a similar pattern:
- Create a FastMCP instance
- Define tools using the
@mcp.tool()
decorator - Run the server with
mcp.run()
For example, the Calculator Server looks like this:
from fastmcp import FastMCP
from typing import Annotated
from pydantic import Field
mcp = FastMCP("Calculator Server")
@mcp.tool()
def sum(
a: Annotated[int, Field(description="The first number")],
b: Annotated[int, Field(description="The second number")]
) -> int:
"""Calculate the sum of two numbers"""
return a + b
if __name__ == "__main__":
mcp.run()
Dependencies
- FastMCP: Python implementation of the Model Context Protocol
- boto3: AWS SDK for Python (for S3 and RDS servers)
- asyncpg: PostgreSQL client library (for PostgreSQL server)
- pydantic: Data validation and settings management
Learning More
To learn more about the Model Context Protocol and FastMCP:
- Model Context Protocol
- FastMCP Documentation
- Amazon Q Documentation
- uv Documentation - Recommended Python package manager for FastMCP
Acknowledgments
This project was inspired by sample-building-mcp-servers-with-rust, which provides a similar implementation of MCP servers using Rust. We thank the authors for their work and inspiration.
推荐服务器

Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。