API reference¶
The existing server exposes two tools. Their names and response shapes are part of the utility client's contract.
Generate a TOTP code¶
generate_totp(secret, digits=6, period=30, algorithm="sha1")
| Argument | Accepted values |
|---|---|
secret |
Base32 secret; spaces, dashes and mixed case are normalized |
digits |
6, 7 or 8 |
period |
Positive integer seconds |
algorithm |
sha1, sha256 or sha512 |
A successful response contains a string code and the seconds left in the period:
{"status": "ok", "data": {"code": "123456", "expires_in": 18}}
Invalid inputs return an INVALID: error string. The example code above is
illustrative; the actual code depends on the secret and current time.
Decode a QR code¶
decode_qr(image_path) reads a local image accessible to the server process.
Pillow opens the image and zxing-cpp decodes exactly one QR code. The tool accepts
a file path; it has no base64 argument.
{"status": "ok", "data": {"payload": "https://example.com/login"}}
Empty or missing paths return INVALID:. Invalid images, images without a QR,
and images containing multiple QRs return DECODE_FAILED:.
Pillow and zxing-cpp are required runtime dependencies and must be installed
before starting the server.
Response helpers¶
Success uses status: "ok"; failure uses status: "error" and one error string:
{"status": "error", "error": "INVALID: image_path is required"}
Response builders for utility MCP tools.
error_response(error)
¶
Build an error response containing the supplied message.
Source code in src/justpen_utility_mcp/responses.py
14 15 16 | |
ok_response(data=None)
¶
Build an ok response, including data only when provided.
Source code in src/justpen_utility_mcp/responses.py
6 7 8 9 10 11 | |
Tool modules¶
The registration functions below attach the documented tools to FastMCP. The Python source is shown without changing the existing runtime implementation.
QR code decoding tool.
register(mcp)
¶
Register the local QR decoding tool on the MCP server.
Source code in src/justpen_utility_mcp/tools/qr.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
TOTP code generation tool.
register(mcp)
¶
Register the Base32 TOTP generation tool on the MCP server.
Source code in src/justpen_utility_mcp/tools/totp.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |