get_rfc
Fetch RFC documents by number to access technical specifications and standards, supporting full text, metadata, or specific sections.
Instructions
Fetch an RFC document by its number
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| number | Yes | RFC number (e.g. "2616") | |
| format | No | Output format (full, metadata, sections) | full |
Implementation Reference
- src/index.ts:197-244 (handler)The MCP tool handler for 'get_rfc' in the CallToolRequestSchema. Validates input, fetches RFC via service, formats output (full/metadata/sections), returns JSON text or error.
case 'get_rfc': { if (typeof typedArgs.number !== 'string') { throw new McpError( ErrorCode.InvalidParams, 'RFC number must be a string' ); } try { const rfc = await rfcService.fetchRfc(typedArgs.number); // Format the output based on the requested format const format = typedArgs.format || 'full'; let result; switch (format) { case 'metadata': result = rfc.metadata; break; case 'sections': result = rfc.sections; break; case 'full': default: result = rfc; break; } return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching RFC ${typedArgs.number}: ${error}`, }, ], isError: true, }; } } - src/index.ts:126-146 (registration)Tool registration in ListToolsRequestSchema, defining name, description, and input schema for 'get_rfc'.
{ name: 'get_rfc', description: 'Fetch an RFC document by its number', inputSchema: { type: 'object', properties: { number: { type: 'string', description: 'RFC number (e.g. "2616")', }, format: { type: 'string', description: 'Output format (full, metadata, sections)', enum: ['full', 'metadata', 'sections'], default: 'full', }, }, required: ['number'], additionalProperties: false, }, }, - src/index.ts:129-144 (schema)Input schema definition for the 'get_rfc' tool, specifying parameters 'number' (required) and optional 'format'.
inputSchema: { type: 'object', properties: { number: { type: 'string', description: 'RFC number (e.g. "2616")', }, format: { type: 'string', description: 'Output format (full, metadata, sections)', enum: ['full', 'metadata', 'sections'], default: 'full', }, }, required: ['number'], additionalProperties: false, - src/services/rfcService.ts:37-65 (helper)Core helper function fetchRfc that retrieves RFC content from IETF URLs (HTML preferred, TXT fallback), parses structure, caches result, returns RfcContent object.
async fetchRfc(rfcNumber: string): Promise<RfcContent> { // Check cache first if (this.cache.has(rfcNumber)) { return this.cache.get(rfcNumber)!; } // Fetch the RFC in both HTML and TXT formats const txtUrl = `${this.baseUrl}/rfc${rfcNumber}.txt`; const htmlUrl = `${this.baseUrl}/rfc${rfcNumber}/`; try { // Try HTML first for better structure const htmlResponse = await axios.get(htmlUrl); const rfc = this.parseHtmlRfc(htmlResponse.data, rfcNumber, htmlUrl); this.cache.set(rfcNumber, rfc); return rfc; } catch (error) { try { // Fallback to TXT format console.error(`Failed to fetch HTML format for RFC ${rfcNumber}, trying TXT format`); const txtResponse = await axios.get(txtUrl); const rfc = this.parseTxtRfc(txtResponse.data, rfcNumber, txtUrl); this.cache.set(rfcNumber, rfc); return rfc; } catch (txtError) { throw new Error(`Failed to fetch RFC ${rfcNumber}: ${txtError}`); } } }