Skip to main content
Glama
Ucode-io

Postman MCP Generator

by Ucode-io

update_data

Modify entity details in the Ucode Items API by specifying the new name and unique identifier. Streamline data updates with direct integration.

Instructions

Update data on the Ucode Items API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe identifier of the entity to be updated.
nameYesThe new name to update in the data.

Implementation Reference

  • The executeFunction implements the core handler logic for the 'update_data' tool: sends a PUT request to update the entity with the given id and new name.
    const executeFunction = async ({ name, 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); // Set up headers for the request const headers = { 'Content-Type': 'application/json', }; // Prepare the body of the request const body = JSON.stringify({ name }); // Perform the fetch request const response = await fetch(url.toString(), { method: 'PUT', headers, body, }); // 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 updating data:', error); return { error: 'An error occurred while updating data.' }; } };
  • The JSON schema defining the input parameters for 'update_data': object with required 'name' (string) and 'id' (integer).
    definition: { type: 'function', function: { name: 'update_data', description: 'Update data on the Ucode Items API.', parameters: { type: 'object', properties: { name: { type: 'string', description: 'The new name to update in the data.' }, id: { type: 'integer', description: 'The identifier of the entity to be updated.' } }, required: ['name', 'id'] } } }
  • lib/tools.js:7-16 (registration)
    The discoverTools() function dynamically imports and collects apiTool objects from all listed tool paths, including 'update_data', preparing them for MCP server registration.
    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-5 (registration)
    Central list of tool file paths; includes the path to the 'update_data' tool implementation, used by discoverTools.
    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'
  • mcpServer.js:40-80 (registration)
    Registers the MCP server handlers for listing tools and calling tools by name; uses the tools array from discoverTools to handle calls to 'update_data'.
    async function setupServerHandlers(server, tools) { server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: await transformTools(tools), })); server.setRequestHandler(CallToolRequestSchema, async (request) => { const toolName = request.params.name; const tool = tools.find((t) => t.definition.function.name === toolName); if (!tool) { throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${toolName}`); } const args = request.params.arguments; const requiredParameters = tool.definition?.function?.parameters?.required || []; for (const requiredParameter of requiredParameters) { if (!(requiredParameter in args)) { throw new McpError( ErrorCode.InvalidParams, `Missing required parameter: ${requiredParameter}` ); } } try { const result = await tool.function(args); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { console.error("[Error] Failed to fetch data:", error); throw new McpError( ErrorCode.InternalError, `API error: ${error.message}` ); } }); }

Other Tools

Related Tools

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/Ucode-io/mcp-server'

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