rr_get_document_upload_url
Generate a secure upload URL for purchase order documents to support inventory management and order processing workflows.
Instructions
Get upload URL for a PO document
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| po_id | Yes | ||
| filename | Yes | ||
| document_type | No | ||
| description | No |
Implementation Reference
- src/index.ts:53-53 (registration)The tool `rr_get_document_upload_url` is registered in the `TOOLS` array.
{ name: 'rr_get_document_upload_url', description: 'Get upload URL for a PO document', inputSchema: { type: 'object' as const, properties: { po_id: { type: 'string' }, filename: { type: 'string' }, document_type: { type: 'string' }, description: { type: 'string' } }, required: ['po_id', 'filename'] } }, - src/index.ts:86-100 (handler)The tool request handler uses the `callApi` function to relay all tool calls to a remote API endpoint.
server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { const result = await callApi(name, (args as Record<string, unknown>) || {}); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true, }; } }); - src/index.ts:57-74 (helper)The `callApi` function handles the execution of the tool logic by sending a POST request to the ReplenishRadar API.
async function callApi(toolName: string, input: Record<string, unknown>): Promise<unknown> { const resp = await fetch(`${BASE_URL}/api/mcp/call`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}`, }, body: JSON.stringify({ tool: toolName, input }), }); if (!resp.ok) { const errorBody = await resp.text(); throw new Error(`API error ${resp.status}: ${errorBody}`); } const data = await resp.json(); return data.result; }