mcp server and mcp browser for testing#821
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Greptile Summary
This PR introduces Model Context Protocol (MCP) functionality to the Stack Auth documentation system. The changes add experimental MCP server support and a browser interface for testing documentation retrieval through the MCP protocol.
The implementation consists of two main components:
-
New Dependencies: Three new packages are added to the docs
package.json:@modelcontextprotocol/sdk(^1.12.0) - Core MCP protocol implementation@vercel/mcp-adapter(^1.0.0) - Vercel-specific MCP integration adapterposthog-node(^4.1.0) - Server-side analytics tracking to complement existing client-side PostHog
-
MCP Browser Interface: A new React component (
docs/src/app/mcp-browser/page.tsx) that provides a web UI for browsing Stack Auth documentation via MCP. The component features a two-panel layout with a document list and content viewer, handling Server-Sent Events (SSE) communication with the MCP server at/api/mcp.
The MCP browser implements custom text parsing logic to handle structured responses from the MCP server, including special handling for different document types like OpenAPI specifications. This suggests the MCP server returns documentation in a structured text format rather than JSON, requiring client-side parsing to extract metadata and content.
This integration allows Stack Auth's documentation to be accessed through the Model Context Protocol, which is commonly used by AI tools and language models to retrieve contextual information from external sources. The testing interface provides a way to validate the MCP implementation before broader deployment.
Confidence score: 3/5
- This appears to be experimental/testing functionality that's relatively safe to merge for development purposes
- The main risk is potential performance issues from the MCP browser's API call handling and lack of error boundaries
- The docs/src/app/mcp-browser/page.tsx file needs attention for potential race conditions and error handling improvements
2 files reviewed, no comments
|
😱 Found 4 issues. Time to roll up your sleeves! 😱 🗒️ View all ignored comments in this repo
Need help? Join our Discord for support! |
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds three dependencies to docs/package.json; implements an MCP API route that lists and returns docs (including OpenAPI extraction for API pages) with PostHog tracking; and adds a React MCP browser page that fetches and displays docs via MCP JSON‑RPC/SSE calls. Changes
Sequence Diagram(s)MCP Browser Page: Document Fetch FlowsequenceDiagram
participant User
participant Client as McpBrowserPage
participant API as /api/mcp
participant Storage as Docs Storage
User->>Client: Open page
Client->>API: POST JSON-RPC list_available_docs
API->>Storage: Read doc summaries (content/, content/docs/, content/api/)
Storage-->>API: Summaries
API-->>Client: SSE/stream JSON with summaries
Client-->>User: Render list
User->>Client: Select doc
Client->>API: POST JSON-RPC get_docs_by_id (id)
API->>Storage: Read doc content (try multiple paths)
alt API page with <EnhancedAPIPage>
API->>Storage: Read referenced OpenAPI JSON file
Storage-->>API: OpenAPI JSON
API-->>API: Extract endpoint details
end
API-->>Client: SSE/stream JSON with doc content (and OpenAPI info if present)
Client-->>User: Render content
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
docs/package.json(3 hunks)docs/src/app/api/[transport]/route.ts(1 hunks)docs/src/app/mcp-browser/page.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (CLAUDE.md)
**/*.{ts,tsx}: TypeScript with strict types, prefertypeoverinterface
Avoid casting toany; Prefer making changes to the API so thatanycasts are unnecessary to access a property or method
Files:
docs/src/app/api/[transport]/route.tsdocs/src/app/mcp-browser/page.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (CLAUDE.md)
**/*.{js,jsx,ts,tsx}: 2-space indentation, spaces in braces, semicolons required
Return promises withreturn await, no floating promises
Proper error handling for async code with try/catch
Use helper functions:yupXyz()for validation,getPublicEnvVar()for env
Switch cases must use blocks
Files:
docs/src/app/api/[transport]/route.tsdocs/src/app/mcp-browser/page.tsx
**/*.{jsx,tsx}
📄 CodeRabbit Inference Engine (CLAUDE.md)
**/*.{jsx,tsx}: React Server Components preferred where applicable
No direct 'use' imports from React (use React.use instead)
Files:
docs/src/app/mcp-browser/page.tsx
🧠 Learnings (5)
📚 Learning: applies to **/*.{jsx,tsx} : no direct 'use' imports from react (use react.use instead)...
Learnt from: CR
PR: stack-auth/stack-auth#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T23:25:51.701Z
Learning: Applies to **/*.{jsx,tsx} : No direct 'use' imports from React (use React.use instead)
Applied to files:
docs/package.jsondocs/src/app/api/[transport]/route.tsdocs/src/app/mcp-browser/page.tsx
📚 Learning: applies to **/*.{js,jsx,ts,tsx} : use helper functions: `yupxyz()` for validation, `getpublicenvvar(...
Learnt from: CR
PR: stack-auth/stack-auth#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T23:25:51.701Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Use helper functions: `yupXyz()` for validation, `getPublicEnvVar()` for env
Applied to files:
docs/package.json
📚 Learning: applies to **/*.{js,jsx,ts,tsx} : proper error handling for async code with try/catch...
Learnt from: CR
PR: stack-auth/stack-auth#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T23:25:51.701Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Proper error handling for async code with try/catch
Applied to files:
docs/src/app/api/[transport]/route.ts
📚 Learning: applies to **/*.{js,jsx,ts,tsx} : return promises with `return await`, no floating promises...
Learnt from: CR
PR: stack-auth/stack-auth#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T23:25:51.701Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Return promises with `return await`, no floating promises
Applied to files:
docs/src/app/api/[transport]/route.ts
📚 Learning: applies to **/*.{jsx,tsx} : react server components preferred where applicable...
Learnt from: CR
PR: stack-auth/stack-auth#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T23:25:51.701Z
Learning: Applies to **/*.{jsx,tsx} : React Server Components preferred where applicable
Applied to files:
docs/src/app/mcp-browser/page.tsx
🧬 Code Graph Analysis (1)
docs/src/app/mcp-browser/page.tsx (2)
docs/src/components/layouts/shared-content-layout.tsx (1)
SharedContentLayout(16-40)docs/src/components/icons.tsx (1)
FileText(207-219)
🪛 GitHub Actions: Run setup tests
docs/package.json
[error] 1-1: pnpm install failed due to outdated pnpm-lock.yaml not matching package.json dependencies. Use 'pnpm install --no-frozen-lockfile' to bypass.
🪛 GitHub Actions: Runs E2E API Tests with external source of truth
docs/package.json
[error] 1-1: pnpm install failed with exit code 1 due to outdated pnpm-lock.yaml. The lockfile is not up to date with package.json dependencies, causing a mismatch in specifiers.
🪛 GitHub Actions: Dev Environment Test
docs/package.json
[error] 1-1: pnpm install failed due to outdated pnpm-lock.yaml not matching package.json specs. Use 'pnpm install --no-frozen-lockfile' to bypass frozen-lockfile restriction.
🪛 GitHub Actions: Runs E2E API Tests
docs/package.json
[error] 1-1: pnpm install failed with exit code 1 due to outdated pnpm-lock.yaml not matching package.json dependencies. Run 'pnpm install' without --frozen-lockfile to update the lockfile.
🪛 Biome (2.1.2)
docs/src/app/api/[transport]/route.ts
[error] 36-36: Unexpected empty object pattern.
(lint/correctness/noEmptyPattern)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: docker
- GitHub Check: all-good
- GitHub Check: Security Check
🔇 Additional comments (1)
docs/src/app/mcp-browser/page.tsx (1)
28-77: Well-implemented MCP tool callerThe
callMcpToolfunction properly handles SSE response parsing and error cases.
|
Claude finished @madster456's task —— View job Comprehensive Code ReviewI've analyzed this MCP server implementation that adds documentation browsing capabilities through the Model Context Protocol. Here's my detailed feedback: 🚨 Critical Issues1. Build Pipeline Failure (BLOCKER)
2. Race Condition in Error Handling (docs/src/app/mcp-browser/page.tsx:133-136)loadDocs().catch(err => {
setError(err instanceof Error ? err.message : 'Failed to load docs');
setLoading(false); // ⚠️ Sets loading after async operation completes
});
3. Bounds Check Missing (docs/src/app/mcp-browser/page.tsx:172-174)const titleDescEnd = textContent.indexOf('\n\n');
if (titleDescEnd !== -1 && titleDescEnd + 2 < textContent.length) {
content = textContent.substring(titleDescEnd + 2); // ⚠️ No bounds checking
|
|
Claude finished @madster456's task —— View job Comprehensive Code ReviewI've analyzed this MCP server implementation that adds documentation browsing capabilities through the Model Context Protocol. Here's my detailed feedback: 🚨 Critical Issues1. Build Pipeline Failure (BLOCKER)
2. Race Condition in Error Handling (docs/src/app/mcp-browser/page.tsx:133-136)loadDocs().catch(err => {
setError(err instanceof Error ? err.message : 'Failed to load docs');
setLoading(false); // ⚠️ Sets loading after async operation completes
});
3. Bounds Check Missing (docs/src/app/mcp-browser/page.tsx:172-174)const titleDescEnd = textContent.indexOf('\n\n');
if (titleDescEnd !== -1 && titleDescEnd + 2 < textContent.length) {
content = textContent.substring(titleDescEnd + 2); // ⚠️ No bounds checking
|
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
docs/package.json (1)
25-25: Update pnpm-lock.yaml to fix CI.New deps added but lockfile is stale; run pnpm install to regenerate pnpm-lock.yaml.
Also applies to: 34-34, 50-50
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (1)
docs/package.json(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: build (22.x)
- GitHub Check: restart-dev-and-test
- GitHub Check: build (22.x)
- GitHub Check: docker
- GitHub Check: lint_and_build (latest)
- GitHub Check: docker
- GitHub Check: all-good
- GitHub Check: setup-tests
- GitHub Check: claude-review
- GitHub Check: Security Check
🔇 Additional comments (2)
docs/package.json (2)
25-25: Deps align with MCP server/browser addition.@modelcontextprotocol/sdk is expected for MCP tools; version range looks fine.
34-34: Adapter dependency looks correct.@vercel/mcp-adapter matches the new API route usage (createMcpHandler).
Important
Introduces an interactive documentation browser and MCP server for testing, with new API handling and enriched API spec display.
route.tsto handle API requests for listing and retrieving documentation using MCP.McpBrowserPageinpage.tsxfor interactive documentation browsing.@modelcontextprotocol/sdk,@vercel/mcp-adapter, andposthog-nodetopackage.json.route.ts.This description was created by
for a80967c. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit
New Features
Chores