get_data
Retrieve specific data from the Ucode Items API by providing a resource ID, enabling streamlined access to targeted information with Postman MCP Generator integration.
Instructions
Get data from the Ucode Items API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the resource to retrieve. |
Implementation Reference
- The core handler function `executeFunction` that performs the HTTP GET request to retrieve data from the Ucode Items API using the provided `id` parameter.const executeFunction = async ({ id }) => { const baseUrl = 'https://postman-rest-api-learner.glitch.me/'; const token = process.env.UCODE_PUBLIC_APIS_API_KEY; try { // Construct the URL with query parameters const url = new URL(`${baseUrl}/info`); url.searchParams.append('id', id); // Perform the fetch request const response = await fetch(url.toString(), { method: 'GET', headers: { 'Content-Type': 'application/json' } }); // Check if the response was successful if (!response.ok) { const errorData = await response.json(); throw new Error(errorData); } // Parse and return the response data const data = await response.json(); return data; } catch (error) { console.error('Error getting data:', error); return { error: 'An error occurred while getting data.' }; } };
- The tool schema definition including name 'get_data', description, input parameters schema (object with required integer 'id'), used for MCP tool registration.name: 'get_data', description: 'Get data from the Ucode Items API.', parameters: { type: 'object', properties: { id: { type: 'integer', description: 'The ID of the resource to retrieve.' } }, required: ['id'] } }
- lib/tools.js:7-16 (registration)The `discoverTools` function that dynamically loads and registers all tools (including get_data) by importing their apiTool exports based on paths.export async function discoverTools() { const toolPromises = toolPaths.map(async (file) => { const module = await import(`../tools/${file}`); return { ...module.apiTool, path: file, }; }); return Promise.all(toolPromises); }
- mcpServer.js:85-86 (registration)Invocation of discoverTools() in the MCP server startup to load the tools array containing the get_data tool.const tools = await discoverTools();
- tools/paths.js:1-6 (helper)Array of tool file paths used for dynamic loading, including the path to get-data.js.export const toolPaths = [ 'ucode-public-apis/ucode-items-ap-is/post-data.js', 'ucode-public-apis/ucode-items-ap-is/get-data.js', 'ucode-public-apis/ucode-items-ap-is/delete-data.js', 'ucode-public-apis/ucode-items-ap-is/update-data.js' ];