今日已更新 255 条资讯 | 累计 37160 条内容
关于我们

Mapping API Path, Query, Header, and Body Parameters to MCP Tool Schemas

Bhavy Shekhaliya 2026年08月29日 11:57 0 次阅读 来源:Dev.to

An API operation can receive input from several places. Path parameters identify the record. Query parameters filter or paginate the result. Headers carry metadata or authentication. The request body contains structured data for create and update operations. An MCP tool should give the AI client one clear input schema. That is the mapping problem: HTTP API inputs path + query + headers + body become MCP tool input one structured schema the AI client can understand This tutorial walks through that mapping with practical examples. The goal is to make the tool easy for an AI client to call without hiding the real API contract. Example API operation Imagine a project-management API with this endpoint: PATCH /workspaces/{workspace_id}/projects/{project_id}/tasks/{task_id} It updates one task. The API accepts: path parameters for workspace_id , project_id , and task_id ; query parameters such as notify_assignee ; a request body with the fields to update; authentication through a Bearer token header; an optional request header such as Idempotency-Key . A shortened OpenAPI-style version might look like this: paths : /workspaces/{workspace_id}/projects/{project_id}/tasks/{task_id} : patch : operationId : updateTask summary : Update a task description : " Update the title, status, assignee, or due date for one task." parameters : - name : workspace_id in : path required : true schema : type : string - name : project_id in : path required : true schema : type : string - name : task_id in : path required : true schema : type : string - name : notify_assignee in : query required : false schema : type : boolean default : false - name : Idempotency-Key in : header required : false schema : type : string requestBody : required : true content : application/json : schema : type : object properties : title : " " type : string status : type : string enum : [ todo , in_progress , blocked , done ] assignee_id : type : string due_date : type : string format : date minProperties : 1 securi

本文内容来源于互联网,版权归原作者所有
查看原文