get_sequence
Retrieve details about mathematical integer sequences from OEIS by providing their ID, such as A000045 for the Fibonacci sequence.
Instructions
Get details about an integer sequence by ID (e.g. A000045)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Sequence ID (e.g. A000045) |
Implementation Reference
- src/index.ts:445-463 (handler)The primary handler function for the 'get_sequence' tool. It validates the sequence ID format, fetches the sequence details using the API client, formats a text response with key information (name, terms, keywords, authors, OEIS ref), and returns it in the MCP content format.private async handleGetSequence(args: { id: string }) { const { id } = args; if (!/^A\d{6,}$/.test(id)) { throw new McpError(ErrorCode.InvalidParams, "id must be a string like A000045"); } const seq = await this.apiClient.getSequence(id); return { content: [ { type: "text", text: `Sequence ${seq.id}: ${seq.name}\n` + `First terms: ${seq.terms.slice(0, 20).join(', ')}${seq.terms.length > 20 ? '...' : ''}\n` + (seq.keywords ? `Keywords: ${seq.keywords.join(', ')}\n` : '') + (Array.isArray((seq as any).authors) && (seq as any).authors.length ? `Authors: ${(seq as any).authors.join(', ')}\n` : '') + (seq.oeisRef ? `OEIS: ${seq.oeisRef}\n` : '') } ] }; }
- src/index.ts:343-350 (schema)The input schema definition for the 'get_sequence' tool, specifying that it requires a string 'id' parameter (e.g., A000045).inputSchema: { type: "object", properties: { id: { type: "string", description: "ID of the integer sequence (e.g. A000045)" } }, required: ["id"], additionalProperties: false }
- src/index.ts:340-351 (registration)The tool registration in the listTools response, defining name, description, and inputSchema for 'get_sequence'.{ name: "get_sequence", description: "Retrieve detailed information about an integer sequence, including its terms, references, links, and keywords. The ID must match the sequence (e.g. A000045).", inputSchema: { type: "object", properties: { id: { type: "string", description: "ID of the integer sequence (e.g. A000045)" } }, required: ["id"], additionalProperties: false } },
- src/index.ts:130-132 (helper)Helper method in LODAApiClient that fetches sequence details from the LODA API endpoint `/sequences/{id}`.async getSequence(id: string): Promise<SequenceDetails> { return this.makeRequest(`/sequences/${id}`); }
- src/index.ts:20-26 (helper)TypeScript interface defining the structure of SequenceDetails returned by the API.interface SequenceDetails { id: string; name: string; terms: string[]; keywords?: string[]; oeisRef?: string | null; }