Skip to main content
Glama
mjpitz
by mjpitz

get_rfc

Fetch and retrieve RFC documents by their number in full text, metadata, or specific sections using the RFC MCP Server.

Instructions

Fetch an RFC document by its number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOutput format (full, metadata, sections)full
numberYesRFC number (e.g. "2616")

Implementation Reference

  • Handler for the 'get_rfc' tool call. Validates the 'number' argument, fetches the RFC using rfcService.fetchRfc(), applies formatting ('full', 'metadata', or 'sections'), and returns the result as 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, }; } }
  • Input schema definition for the 'get_rfc' tool, specifying 'number' as required string and optional 'format' enum.
    { 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:123-187 (registration)
    Registration of available tools including 'get_rfc' in the ListToolsRequestSchema handler.
    // List available tools this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { 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, }, }, { name: 'search_rfcs', description: 'Search for RFCs by keyword', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search keyword or phrase', }, limit: { type: 'number', description: 'Maximum number of results to return', default: 10, }, }, required: ['query'], additionalProperties: false, }, }, { name: 'get_rfc_section', description: 'Get a specific section from an RFC', inputSchema: { type: 'object', properties: { number: { type: 'string', description: 'RFC number (e.g. "2616")', }, section: { type: 'string', description: 'Section title or number to retrieve', }, }, required: ['number', 'section'], additionalProperties: false, }, }, ], }));
  • Core helper function fetchRfc() that implements the RFC fetching and parsing logic (HTML preferred, TXT fallback), with caching. Called by the tool handler.
    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}`); } } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mjpitz/mcp-rfc'

If you have feedback or need assistance with the MCP directory API, please join our Discord server