query_docs
Search and retrieve answers from documents using natural language queries with a Langflow-powered Q&A system.
Instructions
Query the document Q&A system with a prompt
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The query prompt to search for in the documents |
Implementation Reference
- src/index.ts:70-126 (handler)Request handler for CallToolRequestSchema implementing the 'query_docs' tool logic: checks tool name, extracts query, POSTs to API endpoint, extracts text from response, returns as MCP content block, handles axios errors.this.server.setRequestHandler(CallToolRequestSchema, async (request) => { if (request.params.name !== 'query_docs') { throw new McpError( ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}` ); } const { query } = request.params.arguments as { query: string }; try { const response = await axios.post<QueryResponse>( this.apiEndpoint, { input_value: query, output_type: 'chat', input_type: 'chat', tweaks: { 'ChatInput-Jrzyb': {}, 'ChatOutput-rzoZb': {}, 'ParseData-hzL7Q': {}, 'File-2Teuj': {}, 'Prompt-ktajI': {}, 'MistralModel-aLZcw': {} } }, { headers: { 'Content-Type': 'application/json', }, params: { stream: false, }, } ); const result = response.data.outputs[0].outputs[0].results.message.text; return { content: [ { type: 'text', text: result, }, ], }; } catch (error) { if (axios.isAxiosError(error)) { throw new McpError( ErrorCode.InternalError, `API request failed: ${error.message}` ); } throw error; } }); }
- src/index.ts:56-65 (schema)Input schema definition for 'query_docs' tool: object with required 'query' string property.inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'The query prompt to search for in the documents', }, }, required: ['query'], },
- src/index.ts:51-68 (registration)Registers 'query_docs' tool via ListToolsRequestHandler: specifies name, description, and inputSchema.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: 'query_docs', description: 'Query the document Q&A system with a prompt', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'The query prompt to search for in the documents', }, }, required: ['query'], }, }, ], }));
- src/index.ts:12-22 (helper)Type interface QueryResponse for typing the API response structure used in the handler.interface QueryResponse { outputs: Array<{ outputs: Array<{ results: { message: { text: string; }; }; }>; }>; }