feat: add mcp & skills#3992
Conversation
|
🚅 Deployed to the rivet-pr-3992 environment in rivet-frontend
|
How to use the Graphite Merge QueueAdd the label merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR Review: feat: add mcp & skillsSummaryThis PR adds Model Context Protocol (MCP) support and a comprehensive skill system for RivetKit documentation. The changes include a new MCP hub package for serving documentation via MCP and extensive skill documentation. Overall Assessment: ✅ Well-implemented with good test coverage. A few minor suggestions for improvement. Code Quality & Best PracticesStrengths
Suggestions1. Error Handling in CLI (rivetkit-typescript/packages/mcp-hub/src/cli.ts:76-78)The error message in the catch block could be more informative: main().catch((error) => {
console.error("Failed to start docs MCP server", error);
process.exit(1);
});Suggestion: Add structured error logging: main().catch((error) => {
console.error("Failed to start docs MCP server:", {
message: error.message,
stack: error.stack,
});
process.exit(1);
});2. Magic Numbers (rivetkit-typescript/packages/mcp-hub/src/index.ts:27-28)const DEFAULT_LIMIT = 8;Suggestion: Consider making limits configurable via 3. Token Estimation Accuracy (rivetkit-typescript/packages/mcp-hub/src/utils.ts:1-6)The token estimation uses a hardcoded ratio: const TOKEN_RATIO = 1.3;Suggestion: Add a comment explaining this ratio or consider making it configurable since different LLMs may have different tokenization strategies. 4. Shared Transport State (rivetkit-typescript/packages/mcp-hub/src/index.ts:51)let sharedWebTransport: WebStandardStreamableHTTPServerTransport | null = null;Concern: Global mutable state could cause issues in concurrent scenarios. Consider documenting thread-safety expectations or using a singleton pattern with proper initialization guards. Potential Bugs or Issues1. Missing Parent Page HandlingIn const parent = pageMap.get(section.parent_uri);
const sectionTitle = parent ? `${parent.title} › ${section.title}` : section.title;Issue: If parent is missing, it silently falls back to just the section title. This could indicate data integrity issues. Suggestion: Add logging or throw an error if parent is unexpectedly missing since sections should always have valid parents. 2. Cursor Decode Error HandlingIn export function decodeCursor(cursor?: string | null): number {
if (!cursor) return 0;
try {
const decoded = JSON.parse(Buffer.from(cursor, "base64url").toString());
return typeof decoded.offset === "number" && decoded.offset >= 0 ? decoded.offset : 0;
} catch {
return 0;
}
}Suggestion: Consider logging the error or adding validation feedback. Malformed cursors could indicate client bugs that should be surfaced. Security Concerns1. Environment Variable HandlingThe code reads const customPath = process.env.DOCS_METADATA_PATH;
if (customPath) {
const absolutePath = path.isAbsolute(customPath) ? customPath : path.resolve(process.cwd(), customPath);Security: Path traversal could be possible if Suggestion: Validate the path is within expected directories. 2. CLI Body Parsing (cli.ts:54-73)The for await (const chunk of req) {
chunks.push(Buffer.from(chunk));
}Security: Large payloads could cause memory exhaustion. Suggestion: Add a max body size limit (e.g., 1MB for JSON-RPC). Test CoverageStrengths
Gaps
RecommendationsHigh Priority
Medium Priority
Low Priority
ConclusionThis is a solid implementation that adds valuable MCP support to the Rivet ecosystem. The code is well-structured, properly tested, and follows TypeScript best practices. The main concerns are around security hardening (path validation, body size limits) and some edge case handling. With the suggested improvements, this will be production-ready. Recommendation: Approve with minor changes suggested above. Great work on this feature! The MCP integration will significantly improve the developer experience for working with Rivet documentation. 🚀 |
b858ab7 to
ee1ed04
Compare
|
|
||
| async function main() { | ||
| const { server } = createDocsMcpServer(); | ||
|
|
There was a problem hiding this comment.
ee1ed04 to
fe728ec
Compare
fe728ec to
8bab4f6
Compare
8bab4f6 to
04d5349
Compare
| @@ -0,0 +1,79 @@ | |||
| #!/usr/bin/env node | |||
| @@ -0,0 +1,37 @@ | |||
| declare module "@modelcontextprotocol/sdk/server/mcp.js" { | |||
There was a problem hiding this comment.
04d5349 to
6fda95c
Compare
6fda95c to
978f981
Compare
Merge activity
|

No description provided.