THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Mapping Bitcoin Results to MCP Tool Responses

permalink THAMER
#ai-agents#bitcoin#mcp#wab-engine

Research question

A tool response should distinguish engine success from transport success.

MCP tool execution failures can be represented with isError and text content. HTTP 200 alone is insufficient: inspect the WAB ok flag and result envelope. This minimal example deliberately withholds all wallet values and raw error messages; it is an acknowledgement mapper, not a balance formatter. A useful balance tool would validate documented result fields and release only the values authorized by the wallet owner. A timeout is not a zero balance. Protocol-level failures such as unknown methods are handled separately by the MCP server.

Reference implementation

Python · 15 lines
1import json
2
3def tool_result(http_status, envelope):
4    # Minimal disclosure: do not forward raw wallet metadata or errors.
5    if (http_status != 200 or not isinstance(envelope, dict)
6            or envelope.get("ok") is not True
7            or not isinstance(envelope.get("result"), dict)):
8        return {"content": [{"type": "text", "text": "Balance query failed or unavailable."}],
9                "isError": True}
10    return {"content": [{"type": "text", "text": "Balance query succeeded; inspect authorized result locally."}],
11            "isError": False}
12
13if __name__ == "__main__":
14    # Synthetic response, not a live engine result.
15    print(json.dumps(tool_result(200, {"ok": True, "result": {}}), indent=2))

Applying the example

Run python3 result.py with its synthetic fixture. In a real integration, parse a bounded HTTP response before calling the mapper; handle malformed JSON and timeouts as failures. No wallet data is used.

Scope and limitations

This is an independent educational design, not a mandatory SDK or a live-tested integration. The engine remains authoritative. No SEND or recovery tools are exposed. Do not put BTC KEY in tool arguments or model context. Verify the deployed API contract before connecting a wallet.

References

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects