enigma-python-mcp
Enigma Python MCP 服务器
一个 MCP(模型上下文协议)服务器,将 enigmapython 库的功能引入 LLM,允许它们使用历史准确的 Enigma 机器模拟器来加密和解密消息。

此 MCP 服务器已在 Glama.ai 上列出,评分为
功能
公开所有已知的 Enigma 机器型号:Enigma M3、Enigma M4、Enigma I、Enigma K、Enigma Z、Enigma D 等。
动态配置:LLM 可以指定转子、初始位置、环设置、反射器和插线板对进行加密。
本地和网络模式:支持用于本地 MCP 集成(如 Claude Desktop)的
stdio传输,以及用于通过网络公开工具的sse传输。Docker 化:易于跨平台移植和执行。
Related MCP server: MCP Server Example
公开的工具
encrypt_message
使用配置好的 Enigma 机器加密或解密消息。
参数:
machine_model(str):型号名称。支持:'M3','M4','I','I_Norway','I_Sondermaschine','K','K_Swiss','D','Z','B_A133'。message(str):要处理的明文或密文。rotors(list[object]):RotorConfig对象列表。每个对象指定rotor_type(str)、ring_setting(int, 默认=0) 和initial_position(int | str, 默认=0)。重要:列表必须严格按以下顺序排列:[最快/最右侧, 中间, 最慢/最左侧, 希腊转子 (如果是 M4)]。reflector(object):一个ReflectorConfig对象,指定reflector_type(str),以及可选的用于旋转反射器的ring_setting(int) 和initial_position(int | str)。plugboard_pairs(dict, 可选):映射插线板连接的字典(例如{"A": "B", "C": "D"})。
运行服务器
使用 Python
需要 Python 3.11+。
从 PyPI 安装包:
pip install enigmapython-mcp(或者,如果您安装了
uv,只需运行uvx enigmapython-mcp!)通过 stdio 运行(用于本地 MCP 客户端):
enigmapython-mcp --transport stdio通过 SSE 运行(通过网络公开):
enigmapython-mcp --transport sse --host 0.0.0.0 --port 8000
使用 Docker
构建容器:
docker build -t enigmapython-mcp .通过 stdio 运行(默认):
docker run -i enigmapython-mcp通过 SSE 运行:
docker run -p 8000:8000 enigmapython-mcp --transport sse --host 0.0.0.0 --port 8000
客户端配置 (Claude Desktop)
我们提供了两个不同的 mcpb 包,用于在 Claude Desktop 上一键安装。只需从 GitHub Releases 页面下载您喜欢的包,然后将其拖放到 Claude Desktop 的扩展菜单中即可:
enigmapython-mcp-docker.mcpb:极其轻量,依赖于您的本地 Docker 守护进程在隔离容器中运行服务器。(推荐)enigmapython-mcp-python.mcpb:包含完整的 Python 源代码。Claude Desktop 将原生构建虚拟环境并运行服务器,无需 Docker。
如果您更喜欢通过 claude_desktop_config.json 进行手动配置,请使用以下设置:
使用 Python (推荐 uvx)
{
"mcpServers": {
"enigma": {
"command": "uvx",
"args": ["enigmapython-mcp", "--transport", "stdio"]
}
}
}使用 Docker
(注意:请确保先构建了 Docker 镜像:docker build -t enigmapython-mcp .)
{
"mcpServers": {
"enigma": {
"command": "docker",
"args": ["run", "-i", "--rm", "enigmapython-mcp"]
}
}
}客户端配置 (OpenCode)
要将此服务器与 OpenCode 一起使用,请在 mcp 部分下将以下内容添加到您的 ~/.config/opencode/opencode.json(全局)或 opencode.json(项目级)中:
使用 Python (推荐 uvx)
{
"mcp": {
"enigma": {
"type": "local",
"command": [
"uvx",
"enigmapython-mcp",
"--transport",
"stdio"
],
"enabled": true
}
}
}使用 Docker
(注意:请确保先构建了 Docker 镜像:docker build -t enigmapython-mcp .)
{
"mcp": {
"enigma": {
"type": "local",
"command": [
"docker",
"run",
"-i",
"--rm",
"enigmapython-mcp"
],
"enabled": true
}
}
}示例提示词
服务器配置完成后,您可以通过向 LLM 发送以下提示词来测试它:
示例 1:基础加密 (Enigma M3)
"我需要使用 Enigma M3 加密消息 'TOPSECRET'。转子从快到慢依次为 III、II 和 I。所有转子起始位置为 0,环设置均为 0。使用反射器 'UKWB',不使用插线板。密文是什么?"
示例 2:历史解密 (Enigma I)
"解密这条 1930 年的 Enigma I 消息。密文是 'GCDSEAHUGWTQGRK'。机器设置(严格按从快到慢顺序)为:转子 III、I 和 II。它们各自的环设置是 21、12 和 23。它们的初始位置是 11、1 和 0。反射器是 'UKWA'。插线板交换为:A/M, F/I, N/V, P/S, T/U, W/Z。"
示例 3:复杂的 M4 配置
"使用 Enigma M4 加密消息 'DIVE DIVE DIVE'。机器使用 'UKWBThin' 反射器。转子(明确按 [最快, 中间, 最慢, 希腊] 顺序)为:VIII (位置 2), III (位置 6), IV (位置 12), 和 Gamma (位置 21)。所有环设置均为 0。请处理此消息。"
测试
tests/test_server.py 中包含了一套全面的测试套件。它测试了所有 10 种支持的 Enigma 型号的加密和解密可逆性。
运行测试:
# Activate your virtual environment first
source .venv/bin/activate
pip install pytest
export PYTHONPATH=$PYTHONPATH:$(pwd)/src/enigmapython_mcp && pytest tests/* 交互式测试 SSE 服务器
由于模型上下文协议在调用任何工具之前需要有状态的初始化握手,因此使用 curl 手动测试 SSE 端点非常复杂。
测试服务器最简单且官方推荐的方法是使用 MCP Inspector:
确保您的服务器以 SSE 模式运行:
uv run enigmapython-mcp --transport sse --host 0.0.0.0 --port 8000在第二个终端中,启动 Inspector:
npx @modelcontextprotocol/inspector浏览器中将打开一个 Web 界面(通常在
http://localhost:5173)。将 Transport Type 更改为 SSE。
输入
http://localhost:8000/sse作为 URL 并点击 Connect。现在您可以直观地配置并执行
encrypt_message工具了!
Available Tools
1 toolencrypt_messageA
Encrypt or decrypt a message using a specified Enigma machine configuration.
Args:
machine_model: Exact machine model name. MUST be one of: 'M3', 'M4', 'I', 'I_Norway', 'I_Sondermaschine', 'K', 'K_Swiss', 'D', 'Z', 'B_A133', 'T'. Do not add 'Enigma' prefix.
Supported models and their explicitly required reflectors:
- 'M3', 'I': UKWA, UKWB, UKWC
- 'M4': UKWBThin, UKWCThin
- 'I_Norway': UKW_EnigmaINorway
- 'I_Sondermaschine': UKW_EnigmaISonder
- 'K', 'K_Swiss', 'D': UKW_EnigmaCommercial
- 'Z': UKW_EnigmaZ
- 'B_A133': UKW_EnigmaB_A133
- 'T': UKW_EnigmaT
message: The plaintext or ciphertext to process.
- For Enigma Z: MUST contain ONLY digits (1234567890).
- For Enigma B_A133: MUST contain ONLY Swedish letters (abcdefghijklmnopqrstuvxyzåäö). Note: 'w' is strictly forbidden.
- For all other machines: MUST contain ONLY standard letters (A-Z).
- Spaces, punctuation, and special characters are strictly forbidden in all machines.
rotors: List of RotorConfig objects. MUST be ordered exactly as: [Fastest/Rightmost, Middle, Slowest/Leftmost, Greek (if M4)].
reflector: The ReflectorConfig object.
plugboard_pairs: Optional dict for plugboard connections (e.g. {"A": "B", "C": "D"}). Ignored if the machine has no plugboard.
| Name | Required | Description | Default |
|---|---|---|---|
| rotors | Yes | ||
| message | Yes | ||
| reflector | Yes | ||
| machine_model | Yes | ||
| plugboard_pairs | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It adds valuable behavioral context such as message character restrictions per machine model, rotor ordering, and plugboard being ignored when absent. However, it does not disclose return behavior, error handling, or side effects, leaving some transparency gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with the core purpose, then structured as an 'Args' list. It is lengthy due to the complexity, but each line adds necessary value. A slightly more compressed format could be achieved without losing information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complex nested schema and no output schema, the description covers all input parameters thoroughly, including valid values and constraints. It does not explicitly state the return value, but that is implied by the encrypt/decrypt purpose. Overall, it is complete enough for a well-equipped agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has 0% top-level description coverage, but the description provides exhaustive semantics for every parameter: allowed machine models, per-model message constraints, rotor ordering, reflector guidance, and plugboard behavior. This fully compensates for the missing schema documentation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with 'Encrypt or decrypt a message using a specified Enigma machine configuration,' which clearly states the verb and resource. However, there are no sibling tools to differentiate from, so it loses a point for not distinguishing alternatives.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when to use this tool versus alternatives (though there are none), nor any prerequisites, exclusions, or context beyond the first sentence. The detailed parameter constraints are helpful but do not address usage scenarios.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v0.1.4- Changed
encrypt_message1 field changed- changed
Input schema / $defs / ReflectorConfig / properties / reflector_type / descriptionPrevious value: -"Exact Reflector identifier. Valid options: 'UKWA', 'UKWB', 'UKWC', 'UKWBThin', 'UKWCThin', 'UKW_EnigmaCommercial', 'UKW_EnigmaINorway', 'UKW_EnigmaISonder', 'UKW_EnigmaB_A133'."New value: +"Exact Reflector identifier. Valid options: 'UKWA', 'UKWB', 'UKWC', 'UKWBThin', 'UKWCThin', 'UKW_EnigmaCommercial', 'UKW_EnigmaINorway', 'UKW_EnigmaISonder', 'UKW_EnigmaB_A133', 'UKW_EnigmaT'."
1 tool update
v0.1.0- First observed
encrypt_message
TDQS
Scored across 1 tool
Only one tool exists, so there is no ambiguity between tools. The single tool's purpose is clear from its description.
The single tool name 'encrypt_message' follows a clear verb_noun pattern, and there are no other tools to create inconsistency. The name is slightly misleading as it also performs decryption, but this does not affect consistency across tools.
With only one tool, the server feels very thin for an Enigma machine library. However, the single tool is comprehensive, covering encryption and decryption for many machine models.
The tool covers both encryption and decryption, which are the core operations. It also supports a wide range of Enigma models. There could be additional tools for listing models or validating configurations, but these are minor gaps.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
MCP server for AI dialogue using various LLM models via AceDataCloud
Related MCP Servers
- AlicenseDqualityDmaintenanceA Model Context Protocol server that gives LLMs the ability to interact with Ethereum networks, manage wallets, query blockchain data, and execute smart contract operations through a standardized interface.5412 npm14MIT
- AlicenseBqualityDmaintenanceAn educational implementation of a Model Context Protocol server that demonstrates how to build a functional MCP server for integrating with various LLM clients like Claude Desktop.1164MIT
- AlicenseBqualityDmaintenanceAn educational implementation of a Model Context Protocol server that demonstrates how to build a functional MCP server integrating with various LLM clients.2MIT
- FlicenseNot gradedqualityDmaintenanceA foundational implementation of a Model Context Protocol (MCP) server designed for educational purposes. It demonstrates the complete interaction between an LLM, an inference engine, and a client during an agentic call.-