Get NGSS Standard by Code
get_standardLook up a middle school NGSS standard by its code (e.g., MS-PS1-1) and choose the level of detail: minimal, summary, or full.
Instructions
Retrieve a specific NGSS standard by its code identifier (e.g., MS-PS1-1, MS-LS2-3, MS-ESS3-1)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | NGSS standard code (format: MS-{PS|LS|ESS}{number}-{number}) | |
| detail_level | No | Response detail level: minimal (code, topic, PE 50 chars), summary (+ keywords top 3, PE 150 chars), full (complete standard) | full |
Implementation Reference
- src/server/index.ts:103-166 (handler)Tool handler for 'get_standard' that looks up an NGSS standard by code, formats the response based on detail level ('minimal', 'summary', 'full'), and returns it with token metadata.
// Tool 1: get_standard - Lookup standard by code server.registerTool( 'get_standard', { title: 'Get NGSS Standard by Code', description: 'Retrieve a specific NGSS standard by its code identifier (e.g., MS-PS1-1, MS-LS2-3, MS-ESS3-1)', inputSchema: { code: z.string() .regex(/^MS-(PS|LS|ESS)\d+-\d+$/) .describe('NGSS standard code (format: MS-{PS|LS|ESS}{number}-{number})'), detail_level: z.enum(['minimal', 'summary', 'full']) .optional() .default('full') .describe('Response detail level: minimal (code, topic, PE 50 chars), summary (+ keywords top 3, PE 150 chars), full (complete standard)') } }, async ({ code, detail_level }) => { try { ensureInitialized(); const db = getDatabase(); const standard = db.getStandardByCode(code); if (!standard) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'Not Found', message: `Standard ${code} does not exist in the database`, code: 'STANDARD_NOT_FOUND' }, null, 2) }], isError: true }; } const formatted = formatResponse(standard, detail_level as DetailLevel); const tokens = getTokenMetadata(code, formatted); return { content: [{ type: 'text', text: JSON.stringify({ ...formatted, _metadata: { tokens } }, null, 2) }] }; } catch (error) { console.error('get_standard error:', error); return { content: [{ type: 'text', text: JSON.stringify({ error: 'Internal Error', message: error instanceof Error ? error.message : String(error), code: 'INTERNAL_ERROR' }, null, 2) }], isError: true }; } } ); - src/server/index.ts:103-166 (registration)Registration of the 'get_standard' tool on the McpServer instance with input schema and handler.
// Tool 1: get_standard - Lookup standard by code server.registerTool( 'get_standard', { title: 'Get NGSS Standard by Code', description: 'Retrieve a specific NGSS standard by its code identifier (e.g., MS-PS1-1, MS-LS2-3, MS-ESS3-1)', inputSchema: { code: z.string() .regex(/^MS-(PS|LS|ESS)\d+-\d+$/) .describe('NGSS standard code (format: MS-{PS|LS|ESS}{number}-{number})'), detail_level: z.enum(['minimal', 'summary', 'full']) .optional() .default('full') .describe('Response detail level: minimal (code, topic, PE 50 chars), summary (+ keywords top 3, PE 150 chars), full (complete standard)') } }, async ({ code, detail_level }) => { try { ensureInitialized(); const db = getDatabase(); const standard = db.getStandardByCode(code); if (!standard) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'Not Found', message: `Standard ${code} does not exist in the database`, code: 'STANDARD_NOT_FOUND' }, null, 2) }], isError: true }; } const formatted = formatResponse(standard, detail_level as DetailLevel); const tokens = getTokenMetadata(code, formatted); return { content: [{ type: 'text', text: JSON.stringify({ ...formatted, _metadata: { tokens } }, null, 2) }] }; } catch (error) { console.error('get_standard error:', error); return { content: [{ type: 'text', text: JSON.stringify({ error: 'Internal Error', message: error instanceof Error ? error.message : String(error), code: 'INTERNAL_ERROR' }, null, 2) }], isError: true }; } } ); - src/server/index.ts:108-117 (schema)Input schema for the get_standard tool: 'code' (required, regex-validated) and 'detail_level' (optional enum defaulting to 'full').
description: 'Retrieve a specific NGSS standard by its code identifier (e.g., MS-PS1-1, MS-LS2-3, MS-ESS3-1)', inputSchema: { code: z.string() .regex(/^MS-(PS|LS|ESS)\d+-\d+$/) .describe('NGSS standard code (format: MS-{PS|LS|ESS}{number}-{number})'), detail_level: z.enum(['minimal', 'summary', 'full']) .optional() .default('full') .describe('Response detail level: minimal (code, topic, PE 50 chars), summary (+ keywords top 3, PE 150 chars), full (complete standard)') } - src/server/database.ts:153-161 (helper)Database method that validates the code via QueryValidator and performs an O(1) lookup in codeIndex, returning the Standard or null.
getStandardByCode(code: string): Standard | null { // Validate standard code format const validation = QueryValidator.validateStandardCode(code); if (!validation.isValid) { throw new Error(validation.error); } return this.codeIndex.get(validation.sanitized!) || null; } - Formats the standard response according to detail_level: minimal (truncated PE, 50 chars), summary (+ top 3 keywords, PE 138 chars), or full (complete object).
export function formatResponse( standard: Standard, detailLevel: DetailLevel = 'full' ): MinimalStandard | SummaryStandard | Standard { switch (detailLevel) { case 'minimal': return { code: standard.code, topic: standard.topic, performance_expectation: truncateAtWordBoundary(standard.performance_expectation, 50) }; case 'summary': return { code: standard.code, topic: standard.topic, performance_expectation: truncateAtWordBoundary(standard.performance_expectation, 138), keywords: limitKeywords(standard.keywords, 3) }; case 'full': default: return standard; } }