dip:get
Retrieve full text of German parliamentary documents (Bundestagsdrucksachen) by document number, including legislative reasoning and specific sections.
Instructions
Retrieve full text of a Bundestagsdrucksache by Dokumentnummer (e.g., "19/27426" for BT-Drs. 19/27426). Returns the extracted text including Gesetzesbegründung. Use section for partial content or save_path to save to file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dokumentnummer | Yes | Dokumentnummer (e.g., "19/27426", "20/1234") | |
| section | No | Section to extract: heading text (e.g., "Zu § 5 UrhDaG-E", "Begründung", "Zu Artikel 1") or "lines:100-200" | |
| save_path | No | Save full document to this file path instead of returning content |
Implementation Reference
- src/providers/dip/tools/get.ts:7-36 (handler)The `handleGet` function implements the logic for 'dip:get', which retrieves the text of a Drucksache, optionally saving it or extracting a specific section.
export async function handleGet(client: DipClient, args: Record<string, unknown>): Promise<ToolResult> { const { dokumentnummer, section, save_path } = args as { dokumentnummer: string; section?: string; save_path?: string; }; // Search by dokumentnummer in the -text endpoint to get full text const result = await client.searchDrucksachenText({ 'f.dokumentnummer': dokumentnummer, rows: 1 }); if (!result.documents.length) { return { content: [{ type: 'text', text: `Drucksache ${dokumentnummer} not found.` }], isError: true }; } const doc = result.documents[0]; const fullText = doc.text ?? ''; const header = `# BT-Drs. ${doc.dokumentnummer}\n\n**${doc.titel.replace(/\r\n/g, ' ').trim()}**\nDatum: ${doc.datum}\n${doc.fundstelle?.pdf_url ? `PDF: ${doc.fundstelle.pdf_url}` : ''}\n\n---\n\n`; if (save_path) { mkdirSync(dirname(save_path), { recursive: true }); writeFileSync(save_path, header + fullText, 'utf-8'); return { content: [{ type: 'text', text: `Saved to ${save_path} (${fullText.length} chars)` }] }; } if (section) { const extracted = extractSection(fullText, section); return { content: [{ type: 'text', text: extracted }] }; } // Default: return header + first 2000 chars as preview const preview = fullText.length > 2000 ? fullText.slice(0, 2000) + '\n\n[...truncated. Use `section` or `save_path` for full content.]' : fullText; return { content: [{ type: 'text', text: header + preview }] }; } - src/providers/dip/tools/index.ts:23-27 (registration)Registration of the 'dip:get' tool definition and input schema.
name: 'dip:get', description: 'Retrieve full text of a Bundestagsdrucksache by Dokumentnummer (e.g., "19/27426" for BT-Drs. 19/27426). ' + 'Returns the extracted text including Gesetzesbegründung. Use `section` for partial content or `save_path` to save to file.', inputSchema: z.object({