Skip to main content
Glama

rr_get_document_upload_url

Generate a secure upload URL for purchase order documents to manage inventory and stockout risk in Shopify and Amazon stores.

Instructions

Get upload URL for a PO document

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
po_idYes
filenameYes
document_typeNo
descriptionNo

Implementation Reference

  • The callApi function is the generic handler that executes all tool logic including rr_get_document_upload_url. It makes a POST request to the REST API endpoint with the tool name and input parameters, then returns the result.
    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;
    }
  • src/index.ts:53-53 (registration)
    The rr_get_document_upload_url tool is registered in the TOOLS array with name, description, and input schema specifying required parameters po_id and filename, and optional parameters document_type and description.
    { 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'] } },
  • Input schema defines the tool's parameters: po_id (string, required), filename (string, required), document_type (string, optional), and description (string, optional).
    { 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'] } },
  • The CallToolRequestSchema handler receives tool call requests and delegates to the callApi function, handling both successful responses and errors with proper MCP response formatting.
    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,
        };
      }
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ReplenishRadar/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server