post_data
Send data to the Ucode Items API by specifying the name in the request body. Integrates with Postman MCP Generator for API interactions using the Model Context Protocol.
Instructions
Post data to the Ucode Items API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name to be added in the request body. |
Implementation Reference
- The executeFunction that handles the tool logic: posts data to the API endpoint using fetch with the provided 'name' parameter.const executeFunction = async ({ name }) => { const baseUrl = 'https://postman-rest-api-learner.glitch.me/'; const token = process.env.UCODE_PUBLIC_APIS_API_KEY; const data = { name }; try { // Perform the fetch request const response = await fetch(`${baseUrl}/info`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(data), }); // 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 responseData = await response.json(); return responseData; } catch (error) { console.error('Error posting data:', error); return { error: 'An error occurred while posting data.' }; } };
- The apiTool object defining the tool's schema, including name 'post_data', description, and input parameters schema.const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'post_data', description: 'Post data to the Ucode Items API.', parameters: { type: 'object', properties: { name: { type: 'string', description: 'The name to be added in the request body.' } }, required: ['name'] } } } };
- lib/tools.js:7-16 (registration)The discoverTools function that dynamically imports and registers all tools from paths.js, including post_data by loading its apiTool.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); }
- tools/paths.js:1-2 (registration)The toolPaths array that includes the path to the post-data.js tool file, used for dynamic loading.export const toolPaths = [ 'ucode-public-apis/ucode-items-ap-is/post-data.js',