You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[#636] Build MCP action catalog and search/describe/call gateway - #669
[SPRINT-04] MCP: HTTP endpoint and tool wiring in Blade #641: wrap these as tools, serialize errors, and revive Date inputs marked x-forge-native-type: Date. Avoid retrying a mutation after a hook failure since it may have already committed
Test Plan
packages/api/src/tests/mcp/ covers search filtering and ranking, describe on an allowed and a forbidden action, a call denied by a resource check, a permission change applying on the very next call, and hook outcomes
A coverage test walks the router and fails if any meta.mcp procedure is missing from the catalog
pnpm format, pnpm lint, pnpm typecheck, pnpm --filter=@forge/api build and pnpm --filter=@forge/api test pass, 1172 tests
p50 over 100 warm runs with the permission lookup mocked: search 0.017 ms, call 0.052 ms
Merge Danger
Door: two-way. New exports only, nothing calls them yet.
Blast Radius: none until #641 wires the gateway into the MCP endpoint.
Checklist
Database: No schema changes, OR I ran pnpm db:generate and committed the generated files in packages/db/drizzle/
Environment Variables: No environment variables changed, OR I have contacted the Development Lead to modify them on Coolify BEFORE merging.
azizu06
added
Feature
New Feature or Request
Major
Big change - 2+ reviewers required
API
Change modifies code in the global API/tRPC package
labels
Nov 13, 2026
The API package adds MCP access metadata and permission checks for opted-in procedures. It builds a cached action catalog with input schemas derived from Zod validators. The gateway adds authenticated action search, description, and calls. Analytics procedures declare read-access metadata, and the package entry point exports the catalog and gateway APIs. Tests cover access evaluation, catalog construction, gateway behavior, and analytics permission parity.
Merge Risk: Low · previous review d9723
This adds a catalog and gateway for MCP actions with no live callers yet, so production exposure is minimal. One edge case remains: actions with several chained input validators that use registered schema ids could emit input schemas with unresolvable references. Fix it before the follow-up endpoint work relies on those schemas.
Pre-merge checks: 7
Check name
Status
Explanation
Title check
Title starts with issue number in brackets, is 64 characters (under 72), and describes the main change: building the MCP action catalog and the search/describe/call gateway, which matches the changese…
Linked Issues check
[#636] Requirements and evidence: - Catalog walks procedures with meta.mcp, validates, dedupes, and memoizes (utils/mcp/catalog.ts, buildActionCatalog, getActionCatalog). Covered by `tests/mcp…
Out of Scope Changes check
[#636] Changes outside the gateway files: - trpc.ts: permProcedure enforces meta.mcp.access for procedures that declare it. This is needed for the catalog access model. - routers/analytics.ts …
Description check
The description explains the purpose (MCP action listing, describing, and calling for a signed-in member), the new gateway functions, catalog memoization, per-call permission reads, follow-up issues, …
No Hardcoded Secrets
I diffed the PR head against origin/main (the #667 base) and scanned the added lines. The PR changes six files: index.ts, catalog.ts, gateway.ts, and three test files under packages/api/src/tests/mcp/…
Validated Env Access
No process.env access was added in the PR's changed source files. The MCP sources (utils/mcp/access.ts, catalog.ts, gateway.ts), the MCP tests (tests/mcp/*), routers/analytics.ts, `trpc.ts…
No Typescript Escape Hatches
PR #669 (KnightHacks/forge, author azizu06) adds no TypeScript escape hatches. I diffed the PR head against local main (6 files, +798 lines). Findings: - any type: no added line uses the TypeScrip…
Full details: Title check
Explanation
Title starts with issue number in brackets, is 64 characters (under 72), and describes the main change: building the MCP action catalog and the search/describe/call gateway, which matches the changeset.
Full details: Linked Issues check
Explanation
[#636] Requirements and evidence:
Catalog walks procedures with meta.mcp, validates, dedupes, and memoizes (utils/mcp/catalog.ts, buildActionCatalog, getActionCatalog). Covered by tests/mcp/catalog.test.ts.
Input schemas come from existing Zod validators via z.toJSONSchema. Covered by catalog.test.ts.
searchActions returns only accessible actions and supports filtering and ranking. Covered by tests/mcp/gateway.test.ts.
describeAction returns description and schema for allowed actions and rejects disallowed ones. Covered by gateway.test.ts.
callAction runs the real procedure through a server-side caller. A resource-check denial after an action-level pass is covered by gateway.test.ts and perm-procedure.test.ts.
Permissions are read per call. A permission change applies to the next call (gateway.test.ts).
Router coverage: catalog-coverage.test.ts and parity.test.ts check that opted-in procedures appear in the catalog.
Test files were assessed from the change summary. Test contents were not inspected directly.
Full details: Out of Scope Changes check
Explanation
[#636] Changes outside the gateway files:
trpc.ts: permProcedure enforces meta.mcp.access for procedures that declare it. This is needed for the catalog access model.
routers/analytics.ts and utils/analytics/access.ts: analytics procedures declare meta.mcp using new clubAnalyticsReadAccess and hackathonAnalyticsReadAccess rules. The require*AnalyticsRead guards are removed from some handlers. The parity.test.ts tests compare these procedures with the former resolver checks. These changes support the MCP access declarations.
utils/forms/callbacks.ts: adds ForgeTRPCMeta.mcp. Needed for the metadata.
index.ts: re-exports only.
Note: the PR description says blast radius is none. The trpc.ts change applies to existing meta.mcp procedures on the normal tRPC path now. Parity tests cover equivalence but were not run here.
Full details: Description check
Explanation
The description explains the purpose (MCP action listing, describing, and calling for a signed-in member), the new gateway functions, catalog memoization, per-call permission reads, follow-up issues, test coverage, and the new exports. It is directly related to the changeset.
Full details: No Hardcoded Secrets
Explanation
I diffed the PR head against origin/main (the #667 base) and scanned the added lines. The PR changes six files: index.ts, catalog.ts, gateway.ts, and three test files under packages/api/src/tests/mcp/. The scan found no API-key formats (sk-, ghp_, xox, AKIA), no PEM blocks, no credentialed connection strings, no long high-entropy quoted literals, and no password or secret assignments. The only hits were two test-fixture session objects: token: "fixture" in catalog-coverage.test.ts and token: "fixture-token" in gateway.test.ts. These are placeholder values in a mocked Session object. They do not look like credentials and do not match any provider token format. The check targets real hardcoded credentials, so these do not trigger the failure condition. Note that a strictly literal reading of "tokens as string literals" would flag them. I judged that reading against the check's intent and examples.
Full details: Validated Env Access
Explanation
No process.env access was added in the PR's changed source files. The MCP sources (utils/mcp/access.ts, catalog.ts, gateway.ts), the MCP tests (tests/mcp/*), routers/analytics.ts, trpc.ts, utils/analytics/access.ts, utils/forms/callbacks.ts, and index.ts contain no process.env references. A repository-wide search of packages/api/src, excluding env.ts and tests, finds one match: utils/career/globe-cities.ts:148. That file is not in the PR's summarized change list. The PR is a single squashed commit (8ede2e6) with no usable parent, so the base diff could not be confirmed. The globe-cities.ts line is therefore treated as pre-existing. Other process.env hits are in env.ts (allowed) and in integration/unit test files (DATABASE_URL, BLADE_E2E_AUTH). None of those test files is in the PR's listed changes. Config files (vitest.config.ts, drizzle.config.ts) are allowed by the check.
Full details: No Typescript Escape Hatches
Explanation
PR #669 (KnightHacks/forge, author azizu06) adds no TypeScript escape hatches. I diffed the PR head against local main (6 files, +798 lines). Findings: - any type: no added line uses the TypeScript any type. The any matches are string literals for the MCP access mode (mode: "any", z.enum(["any", "all"]), and zod unrepresentable: "any"). - @ts-ignore, @ts-expect-error, @ts-nocheck: none found. - Non-null assertions (x!, x!., x![, x!)): none found. The only ! hits are !==/!= comparisons. The PR does add as type assertions (for example router._def.procedures as Record<string, AnyProcedure> in catalog.ts and as ForgeTRPCMeta | undefined in gateway.ts and catalog.ts). The check does not list type assertions as a failure condition, so they do not affect this verdict. Note: the raw summary lists changes to analytics.ts, trpc.ts, and utils/mcp/access.ts. Those files do not differ from local main, so they are likely in the base from PR #667. This check reviewed only the diff that is present.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
Other comments: 1
packages/api/src/utils/mcp/catalog.ts: 1
86-86: Minor · Data Integrity & Integration · Quick win
Preserve $ref targets when combining input schemas.
For chained .input() validators, a nested z.string().meta({ id: "Slug" }) produces #/$defs/Slug. Wrapping the converted schema in allOf moves its $defs below allOf/0, but the reference still targets the document root. Schema consumers cannot resolve that reference. (raw.githubusercontent.com)
Combine the Zod validators before JSON Schema conversion so references use the final document root.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
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
APIChange modifies code in the global API/tRPC packageFeatureNew Feature or RequestMajorBig change - 2+ reviewers required
2 participants
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.
Why
#641 needs a way to list, describe and run MCP actions for a signed-in member without skipping the checks Blade already runs.
What
Closes: #636
Part of #634
Based on
mainafter #667 merged.buildActionCatalog(appRouter)walks every procedure withmeta.mcp, validates and dedupes it, and memoizes the resultz.toJSONSchemaFollow-ups:
onToolCalltorecordMcpActivityDateinputs markedx-forge-native-type: Date. Avoid retrying a mutation after a hook failure since it may have already committedTest Plan
packages/api/src/tests/mcp/covers search filtering and ranking, describe on an allowed and a forbidden action, a call denied by a resource check, a permission change applying on the very next call, and hook outcomesmeta.mcpprocedure is missing from the catalogpnpm format,pnpm lint,pnpm typecheck,pnpm --filter=@forge/api buildandpnpm --filter=@forge/api testpass, 1172 testsMerge Danger
Door: two-way. New exports only, nothing calls them yet.
Blast Radius: none until #641 wires the gateway into the MCP endpoint.
Checklist
pnpm db:generateand committed the generated files inpackages/db/drizzle/