v0.7.0 — MCP server (any AI client can use AgentMark) - #6
Merged
Conversation
Wraps every public surface — web browser, PDF documents, AcroForm
filling, OCR — as a Model Context Protocol server. Any MCP client
(Claude Desktop, Cursor, Claude Code, custom agents) can use AgentMark
through one configuration entry. No SDK install, no language commitment.
Configure in any MCP client:
{
"mcpServers": {
"agentmark": {
"command": "npx",
"args": ["-y", "@thinkfleet/agentmark", "agentmark-mcp"]
}
}
}
15 tools exposed
- Browser (3): browser_open / browser_close / browser_save_session
- Page (5): page_open / page_navigate / page_snapshot / page_execute / page_close
- PDF (6): pdf_open (file path or data: URI) / pdf_close / pdf_snapshot /
pdf_execute / pdf_save (with optional flatten) / pdf_reset
- Meta (1): list_sessions for debugging stuck connections
Architecture
- src/mcp/tool-defs.ts: declarative tool catalog with full JSON Schema
input descriptions
- src/mcp/dispatcher.ts: pure dispatch function — name + args → result.
Stateless except for the session registries it
receives. Tested directly without transport.
- src/mcp/server.ts: MCP Server wiring + StdioServerTransport binding +
SIGINT/SIGTERM cleanup
- src/mcp/cli.ts: Bin entry (#!/usr/bin/env node) — what npm
installs as `agentmark-mcp` on PATH
Stateful session model
- Long-lived browsers + pages + opened PDF documents are held server-side,
keyed by short opaque IDs returned from _open calls. Agents can drive
multiple parallel surfaces from one MCP connection.
- All resources auto-released on disposeAll() — invoked on shutdown
via SIGINT/SIGTERM and exposed for tests.
Programmatic API
- createMcpServer() / startMcpServer() exported for embedding the
server in larger applications.
- dispatch() exported for tests / custom transports.
Optional peer dependency
- @modelcontextprotocol/sdk@^1 added as optional peer. Library callers
who don't run the MCP server pay no install cost.
bin entry
- package.json now has "bin": { "agentmark-mcp": "./dist/src/mcp/cli.js" }
- npm sets executable bit on install; shebang preserved through tsc
Tests (213 unit + 10 real-Chromium = 223 total, was 199)
- 14 dispatcher tests:
- tool registry shape (uniqueness, naming prefix, schema validity)
- error semantics (unknown tool, missing args, unknown session ID,
AgentMark error code prefix surfacing)
- PDF round trip (open → snapshot → execute → save with file IO)
- reset clears pending values
- data-URI PDF source (base64 in-memory loading)
- list_sessions (empty + populated)
- disposeAll closes everything
- 4 wire-level handshake tests via InMemoryTransport — exercises the
full MCP protocol (handshake, ListTools, CallTool, error responses)
without spawning a subprocess
Distribution unlocked
After npm publish, anyone can configure AgentMark in any MCP client with
the snippet above. The full SDK (web + PDF + OCR + AcroForm fill/save)
becomes available as 15 tools any agent can call.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wraps every public surface — web browser, PDF documents, AcroForm filling, OCR — as a Model Context Protocol server. Any MCP client (Claude Desktop, Cursor, Claude Code, custom agents) can use AgentMark through one configuration entry. No SDK install, no language commitment.
Stacked on top of #5 (v0.6 AcroForm). Merge #2 → #3 → #4 → #5 → this PR.
One-line install for any MCP client
```json
{
"mcpServers": {
"agentmark": {
"command": "npx",
"args": ["-y", "@thinkfleet/agentmark", "agentmark-mcp"]
}
}
}
```
15 tools exposed
Each tool ships with a full JSON Schema for inputs — clients see usage hints, parameter docs, and validation automatically through MCP's `tools/list`.
Architecture
The dispatcher / server split means tests can drive the full protocol without spawning subprocesses.
Stateful session model
Long-lived browsers + pages + opened PDFs held server-side, keyed by opaque IDs returned from `_open` calls. Agents can drive multiple parallel surfaces from one connection. All resources auto-released on shutdown.
Tests (223 total, 18 new for MCP)
Optional peer dependency
`@modelcontextprotocol/sdk` is an optional peer dep. Library callers who don't run the MCP server pay no install cost; SDK users still get the full library.
Test plan
🤖 Generated with Claude Code