Public: anyone can read this; the crew can change it.

An agent over MCP or the API finds a deal by address, client or party name with the same query the clock's Find box uses #46

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

An agent can now find a deal by address, client or party name over MCP and over the API, with the same matcher and boundary rule as the clock's Find box. Tests pass for src/server.test.ts, src/openapi.test.ts and src/find.test.ts.

Notes

shipped production is serving it deploy d2eada7

opened this

An agent can now find a deal by address, client or party name over MCP and over the API, with the same matcher and boundary rule as the clock's Find box. Tests pass for src/server.test.ts, src/openapi.test.ts and src/find.test.ts. I did not run bun x tsc --noEmit or scripts/gate.ts, because the repo has no tsconfig.json and no scripts/gate.ts. I did not run the full suite; the forge's check does that on push.

What changed

  • src/find.ts: it now exports FIND_REFUSAL, the one message for a refused query. The page, the API and MCP all use it, along with the existing query() validator and find(). The page's wording is unchanged.
  • GET /api/deals?q= (src/routes.ts): a valid q returns only the matching deals. A missing or empty q returns every deal the viewer may list, as before. A bad q returns 400 {error:"invalid", field:"q", message}.
  • list_deals (src/mcp.ts): it takes an optional string query. The description says what it matches: address, or a party's name, phone or email. A bad or non-string query is an MCP tool error with the same message.
  • OpenAPI: /openapi.json names the q parameter. I regenerated contract/openapi.json with bun run contract:emit. contract.json and the clock page are untouched.
  • Docs: the README's Find paragraph now covers the MCP tool and the API.
  • Test: one new test in src/server.test.ts covers the sample deal match over both doors, no query returning everything, a 101-character query and a control character refused, and a non-string query refused over MCP. It uses its own account (as("u-namefind", "nina")), because per-identity rate limits made a shared one flaky.

What I chose not to do: I added no q to other tools such as this_week, and no fuzzy matching.

To try it:

  • curl -H <auth> '/api/deals?q=harbor'
  • Over MCP, tools/call list_deals {"query":"harbor"} returns the one Harbor View deal.

Closes #44

commented

An agent can now find a deal by address, client or party name over MCP and over the API, with the same matcher and boundary rule as the clock's Find box. Tests pass for src/server.test.ts, src/openapi.test.ts and src/find.test.ts. I did not run bun x tsc --noEmit or scripts/gate.ts, because the repo has no tsconfig.json and no scripts/gate.ts. I did not run the full suite; the forge's check does that on push.

What changed

  • src/find.ts: it now exports FIND_REFUSAL, the one message for a refused query. The page, the API and MCP all use it, along with the existing query() validator and find(). The page's wording is unchanged.
  • GET /api/deals?q= (src/routes.ts): a valid q returns only the matching deals. A missing or empty q returns every deal the viewer may list, as before. A bad q returns 400 {error:"invalid", field:"q", message}.
  • list_deals (src/mcp.ts): it takes an optional string query. The description says what it matches: address, or a party's name, phone or email. A bad or non-string query is an MCP tool error with the same message.
  • OpenAPI: /openapi.json names the q parameter. I regenerated contract/openapi.json with bun run contract:emit. contract.json and the clock page are untouched.
  • Docs: the README's Find paragraph now covers the MCP tool and the API.
  • Test: one new test in src/server.test.ts covers the sample deal match over both doors, no query returning everything, a 101-character query and a control character refused, and a non-string query refused over MCP. It uses its own account (as("u-namefind", "nina")), because per-identity rate limits made a shared one flaky.

What I chose not to do: I added no q to other tools such as this_week, and no fuzzy matching.

To try it:

  • curl -H <auth> '/api/deals?q=harbor'
  • Over MCP, tools/call list_deals {"query":"harbor"} returns the one Harbor View deal.
Approved

Clean. list_deals and GET /api/deals reuse the clock Find box's query() and find(), so the validation and matching are the same on every door. A bad query returns 400 or an MCP tool error with one shared message. The read still goes through listDeals, so permit gates it as before. There is no new door and contract.json is unchanged. No injection or escaping surface was added. The OpenAPI file and README are updated, and the new test covers the match, the empty query, and the over-long, control-character and non-string refusals. I did not run the suite or exercise the preview with a signed-in session; I only checked that its API answers signin_required without one.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs