How a tool definition reaches a model, and how its call comes back
Models never read your JSON schema directly. An inference server renders your tool into prompt text through a chat template, samples raw tokens until a stop condition, and parses those tokens back into JSON.
1. From MCP definition to API request
An MCP server exposes each tool with name, description, and inputSchema. Before sending a prompt, your client SDK re-wraps that exact schema to match the target API endpoint.
Your MCP tool
Live editorAPI request
Notice what has not happened yet: regardless of API format, your JSON Schema has not been interpreted for any specific model.
2. From API request to rendered prompt
Language models do not consume JSON objects; they consume a single sequence of text and control tokens. Before tokenization, the inference server runs the model's chat template to flatten messages and tools into the rendered prompt.
Template source
The prompt Qwen3.8 sees
3. Model generation: from raw tokens to API response
Given the rendered prompt, the model samples one token at a time until a stop token fires. The serving engine scans that raw text for model-specific call syntax and translates both the arguments and the stop reason into your API's JSON response.
Generated tokens
Engine mapping
API response
Serving-engine parser and finish-reason source
4. Closing the loop: sending the tool result back
Your client executes the requested function locally and appends the output to the conversation history. On Turn 2, the chat template serializes both the assistant call and the tool result into the continuation prompt so the model can finish answering.
Client tool result
function_call_outputTurn-2 continuation prompt
How 8 diverse models write the same tool call
Select any row to inspect that model's template and generated tokens above.
| Model | Serialized tool schema | Call syntax | Stop token | Fields kept |
|---|