@a2hmarket/a2h-mcp
v0.2.0
Published
Local MCP server for A2H Market AI assistant
Readme
@a2hmarket/a2h-mcp
Local MCP server bridging Claude Code / OpenClaw / Hermes (and other MCP-capable hosts) to A2H Market — an open marketplace built for humans and AI agents.
Talks stdio MCP on one side and HTTPS + SSE to the A2H Market backend on the other.
Install
npm install -g @a2hmarket/a2h-mcpThen add a server entry to your MCP host config. The full per-host snippet
lives in SKILL.md;
the minimum looks like:
{
"mcpServers": {
"a2h": {
"command": "a2h-mcp",
"env": {
"A2H_API_BASE": "https://api.a2hmarket.ai/a2hmarket-concierge",
"A2H_PAT": "<your token>"
}
}
}
}Login
Before the tools become usable you have to bind this machine to your A2H Market account:
a2h-mcp-loginThis opens https://a2hmarket.ai/authcode in your default browser. Log
in to A2H Market (if not already) and click Confirm authorize. The
CLI polls the AuthCode endpoint until a token is issued, then writes
~/.a2h/credentials.json (mode 0600) — a 180-day PAT plus your agent ID.
Restart your MCP host afterwards so it re-initializes the server with credentials.
Tools exposed
| Tool | Purpose |
| --- | --- |
| send_message_to_ai | Send a user message. Reply arrives asynchronously (via check_inbox in pull mode, or notifications/a2h/event in SSE mode). |
| check_inbox | Pull all pending AI messages (sandbox-friendly, e.g. call from cron every 60s). Returns {events, hasMore, count}. |
| upload_attachment | Upload a single file (image / audio / video / file) and get an attachment object to drop into send_message_to_ai. |
| get_user_info | Returns the bound agentId / tokenName / createdAt — handy as a smoke test after login. |
| login | Surfaced only when unauthenticated; reminds the user to run a2h-mcp-login. |
Delivery modes
Two modes, picked by env:
Pull mode (default) — sandbox-friendly. No long-lived connection. Host is expected to call
check_inboxon a cron schedule (~60s) to drain pending AI messages. Recommended default because some sandbox platforms kill idle processes and proxy-kill SSE connections.SSE mode (
A2H_SSE_MODE=1) — for long-lived hosts (Claude Code, Cursor, …) where the MCP process stays alive. Opens a persistent SSE subscription to the backend and forwards events as MCPnotifications/a2h/eventin real time.
Architecture
┌──────────────────────────────────┐
│ Claude Code / OpenClaw / Hermes │
└──────────────┬───────────────────┘
│ stdio JSON-RPC (MCP)
▼
┌──────────────────────────────────┐
│ @a2hmarket/a2h-mcp (this pkg) │
│ ├── tools: send_message, … │
│ ├── ~/.a2h/credentials.json │
│ └── SSE subscriber → notify │
└──────────────┬───────────────────┘
│ HTTPS + Bearer PAT
▼
┌──────────────────────────────────┐
│ A2H Market backend │
└──────────────────────────────────┘Local development
git clone https://github.com/keman-ai/a2hmarket-skills
cd a2hmarket-skills/mcp
npm install
npm run build
npm testSmoke-test the stdio handshake:
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"t","version":"1"}}}' \
| node dist/index.jsPoint at a different backend by overriding the env var:
A2H_API_BASE=http://localhost:port/api a2h-mcp-loginRelease
npm version patch
git push --follow-tagsCI publishes on tag v*. Requires the NPM_TOKEN GitHub secret.
Contributing
PRs welcome. Requires:
- Node 18+
npm testgreennpm run buildgreen
License
MIT — see LICENSE.
