MCP Number Powers Server
Exposes tools to calculate powers (square, cube, etc.) of a number via stdio or HTTP/SSE, with an additional resource and prompt on the HTTP variant.
README
MCP Server Sample
A sample repository demonstrating two ways to run an MCP (Model Context Protocol) server using Python: stdio (local subprocess) and HTTP/SSE (remote HTTP).
What It Does
Both servers expose a calculate_powers tool that computes the square, cube, and 4th power of a number. The HTTP server also adds a calculate_negative_powers tool, a numberpowers://info resource containing historical notes about number powers, and a powers_explanation prompt.
Project Structure
├── server.py # Stdio MCP server (single tool)
├── server_http.py # HTTP/SSE MCP server (two tools + resource)
├── requirements.txt # Python dependencies
├── numberPowers.txt # Text file served as a resource
├── opencode.json # opencode config for HTTP server
└── stdioMcpServerConfig.json # opencode config template for stdio server
Prerequisites
- Python 3.10+
- An MCP-compatible client (e.g., opencode)
Setup
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
Running the Servers
Stdio Server (server.py)
The stdio server runs as a subprocess and communicates over stdin/stdout. It exposes one tool: calculate_powers.
python server.py
HTTP/SSE Server (server_http.py)
The HTTP server runs on http://localhost:8000 and communicates over Server-Sent Events (SSE). It exposes two tools (calculate_powers, calculate_negative_powers), one resource (numberpowers://info), and one prompt (powers_explanation).
python server_http.py
The SSE endpoint is available at http://localhost:8000/sse.
Adding to opencode
Option 1: Stdio (local subprocess)
Add the following to your opencode.json in the project root:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"number-powers": {
"type": "local",
"command": ["python", "server.py"],
"enabled": true
}
}
}
Adjust the command array to use absolute paths if needed (e.g., ["/path/to/venv/bin/python", "/path/to/server.py"]).
Option 2: HTTP/SSE (remote server)
Start the HTTP server first (python server_http.py), then add this to your opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"number-powers-http": {
"type": "remote",
"url": "http://localhost:8000/sse",
"enabled": true
}
}
}
Applying Changes
After saving opencode.json, restart opencode for the MCP server to be available.
Available MCP Capabilities
| Server | Type | Tools | Resources | Prompts |
|---|---|---|---|---|
server.py |
stdio | calculate_powers(number) |
— | — |
server_http.py |
HTTP/SSE | calculate_powers(number), calculate_negative_powers(number) |
numberpowers://info |
powers_explanation(number) |
Tool Details
calculate_powers — Accepts a number, returns its square, cube, and 4th power as a comma-separated string.
calculate_negative_powers — Accepts a number, returns its negative powers (n^-1, n^-2, n^-3) as a comma-separated string. (HTTP server only)
numberpowers://info — Returns historical notes about number powers from ancient civilizations. (HTTP server only)
Prompt Details
powers_explanation — Accepts a number and returns a prompt asking the LLM to calculate and explain all powers of that number (square, cube, 4th power, and negative powers). (HTTP server only)
Invoking Prompts in OpenCode
OpenCode supports invoking MCP prompts through the chat interface. To use the powers_explanation prompt:
- Start the HTTP server:
python server_http.py - In OpenCode, mention the prompt in your message, for example:
Use the powers_explanation prompt for number 22 - OpenCode will call the MCP server's
prompts/getendpoint with the prompt name and arguments.
Alternatively, you can manually invoke the prompt via the MCP protocol:
{
"method": "prompts/get",
"params": {
"name": "powers_explanation",
"arguments": {
"number": 22
}
}
}
License
See LICENSE.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。