What Is Function Calling? LLM Tool Schemas Explained

What Is Function Calling?

Scrapeless MCP Server exposes web and browser capabilities that an agent host can present to a model through function-calling interfaces.

TL;DR

  • Function calling is structured model output. The model requests a named tool with arguments; application code validates and executes it.
  • The model does not run the function. Credentials, network access, side effects, and result handling remain in the host application.
  • Schemas shape reliability. Clear names, descriptions, required fields, enums, and bounded values reduce ambiguous calls.
  • Validation is still required. Schema-valid arguments can be unauthorized, unsafe, stale, or wrong for the current state.
  • Tool results continue the conversation. The application returns the function outcome so the model can answer or choose another permitted step.

Why This Topic Matters

Function calling is a pattern that lets an application describe tools to a language model and receive a structured request to use one of them. The OpenAI function calling documentation explains that tool definitions use schemas and that the application executes the selected function. The model produces a proposal; it does not gain direct access to a server, database, browser, or credential.

This separation makes language models useful inside software. Natural-language intent can map to a typed operation, while existing application code retains authorization and business rules. Function calling can power read-only search, calculations, record lookup, browser operations, or transactions. The risk and validation required depend on the side effect, not on how clean the JSON looks.

The Function-Calling Lifecycle

The host sends the model a user request and a set of available tool definitions. Each definition has a name, description, and input schema. The model may answer directly or return a tool call with structured arguments. The host parses that call, checks it, executes the corresponding code, and sends the result back under the correct call identity.

The model can then use the result to produce a final answer or request another tool. Multi-step tool use creates an agentic loop, but function calling itself is only the interface between the model and the host. Planning, memory, authorization, scheduling, and error policy are separate application concerns.

A well-designed tool represents one meaningful capability. A vague tool such as `do_anything` hides permissions and gives the model too many argument combinations. A narrow search function, customer lookup, or browser navigation operation is easier to describe, validate, observe, and grant independently.

What Makes a Good Tool Definition

  • Clear name. Use a verb and object that distinguish the capability from nearby tools.
  • Decision-focused description. Explain when the tool should be used, what it returns, and important exclusions.
  • Constrained schema. Require needed fields and use enums, formats, bounds, and nested objects deliberately.
  • Typed result. Return stable fields, source evidence, action status, and machine-readable errors.
  • Explicit side effect. Make read, write, send, delete, submit, and purchase behavior obvious to the host and model.

Function Calling, APIs, and MCP

These concepts operate at different layers and often work together rather than competing.

ConceptRoleKey boundary
Function callingModel requests a typed operationHost chooses whether and how to execute
APISoftware service exposes an operationAuthentication and business rules live at the service
MCPServer advertises tools and data to compatible hostsHost decides which discovered capabilities reach the model
AgentCoordinates goals, state, tools, and evaluationAutonomy is bounded by policy and stop rules
Computer useOperates a graphical interfaceActions require current visual or semantic state

Implement a Safe Function-Calling Loop

Treat every tool call as untrusted input proposed by the model. Apply the same authorization and validation expected from any other client.

  1. Inventory capabilities. Split operations by resource, side effect, and permission so each tool has one understandable contract.
  2. Design schemas from real functions. Match actual required inputs and output fields instead of inventing model-friendly parameters that code cannot honor.
  3. Validate context and authority. Check identity, resource ownership, current state, allowed values, budgets, and approvals before execution.
  4. Return precise results. Include stable identifiers, evidence, and structured error categories without exposing secrets or internal stack traces.
  5. Log the full exchange. Record the tool definition version, requested arguments, validation outcome, execution result, and model-visible response.

Evaluate Tool Use

A tool-calling evaluation should distinguish selection, argument formation, execution, and final-answer use.

  • Selection accuracy. Did the model choose the correct tool or correctly avoid tool use?
  • Argument validity. Did the call satisfy schema and task-specific semantic constraints?
  • Authorization behavior. Did the host block disallowed resources and require approvals at the right boundary?
  • Result use. Did the model interpret the returned fields and evidence without adding unsupported claims?
  • Loop control. Did multi-step use stop on completion, non-progress, or budget exhaustion?

Function-Calling Risks

Structured output improves parsing but does not make model decisions trustworthy by itself. The NIST AI Risk Management Framework supplies a governance frame, while the HTTP semantics specification reminds implementers that network responses have precise semantics that the host must interpret. Security remains an application responsibility.

  • Overbroad tools. Large capabilities make least-privilege authorization and meaningful evaluation difficult.
  • Semantic invalidity. Arguments can pass JSON Schema yet refer to the wrong account, stale record, or prohibited target.
  • Injection through tool results. External content can contain instructions. Return it as data and preserve system policy precedence.
  • Secret leakage. Tool definitions and results should not expose credentials, private routing, or unnecessary personal data.
  • Duplicate side effects. The host should use operation identities and current-state checks so repeated model calls do not create unintended writes.

Function-Calling Use Cases

Current information

Let the model request search or retrieval and receive source-bearing results.

Business lookup

Translate a user question into a validated query against an approved service.

Web operations

Expose browser actions as narrow capabilities with session and domain policy.

Workflow assistance

Prepare a structured write operation and require application or human approval before commitment.

From Pilot to Production

A useful pilot for function calling should be small enough to inspect record by record. Begin with inventory capabilities: Split operations by resource, side effect, and permission so each tool has one understandable contract. Then apply design schemas from real functions: Match actual required inputs and output fields instead of inventing model-friendly parameters that code cannot honor. Keep the first evaluation set deliberately mixed, including ordinary cases, ambiguous cases, missing evidence, and an action the system must decline or hand off. This reveals whether the workflow understands its boundary before higher volume hides design mistakes inside aggregate metrics.

Production readiness requires an owner for every measure and artifact. Track selection accuracy to answer whether did the model choose the correct tool or correctly avoid tool use? Track argument validity to determine whether did the call satisfy schema and task-specific semantic constraints? Add authorization behavior so the team can see whether did the host block disallowed resources and require approvals at the right boundary? These measures should link to underlying records rather than exist only as dashboard totals. A reviewer needs to move from a changed metric to the exact query, source, observation, or action that produced it.

Operational controls should target the failure modes most likely to change a business decision. The first review rule should cover overbroad tools: Large capabilities make least-privilege authorization and meaningful evaluation difficult. The exit review should cover duplicate side effects: The host should use operation identities and current-state checks so repeated model calls do not create unintended writes. Assign a response owner, define what evidence resolves the issue, and record whether the outcome changes data, prompts, tools, permissions, or source policy. That record prevents the same defect from being rediscovered as an unexplained quality fluctuation.

Expand only after the pilot behaves predictably. A team may begin with current information, where the job is to let the model request search or retrieval and receive source-bearing results. A second phase can add business lookup, where the workflow must translate a user question into a validated query against an approved service. Keep the original test set running as scope grows. New sources, markets, tools, and permissions should be introduced one boundary at a time so regressions can be assigned to a specific change instead of a simultaneous platform rewrite.

Conclusion

Function calling gives language models a typed way to request software capabilities. Its reliability comes from the surrounding host: accurate schemas, semantic validation, least privilege, deterministic authorization, stable results, and complete traces. The model selects; the application remains responsible.

Start with read-only tools and a short capability set. Evaluate selection and arguments on real tasks before adding side effects. That sequence turns natural-language flexibility into controlled software behavior.

Ready to Expose Web Tools to an Agent Host?

Use Scrapeless MCP Server and Agent Browser to make bounded web capabilities available through structured tool interfaces.

Sign up today and get $5 in free creditno credit card required.

Claim Your $5 Credit →

FAQ

Does function calling execute code inside the LLM?

No. The model emits a structured tool request. The host application validates it, executes its own code or service call, and returns the result to the model.

Is function calling the same as an API?

No. An API exposes a software operation. Function calling is a model-facing pattern for requesting an operation. Application code often maps a function call to one or more APIs.

Is MCP the same as function calling?

No. MCP standardizes how hosts connect to capability servers and discover tools or resources. A host may present selected MCP tools to a model through its function-calling interface.

Does JSON Schema make a tool call safe?

No. Schema validation checks structure and some value constraints. The host must still verify identity, ownership, authorization, business rules, current state, and side-effect approval.

How many functions should a model receive?

Use the smallest relevant set for the task. Too many overlapping tools increase selection ambiguity and make permissions harder to reason about. Tool routing can narrow a larger catalog before model choice.

References