Skip to content

Function calling reference ​

This page lists every field and option. The overview shows what it does and a first example.

With tools, an LLM can call other resources during a response. When the LLM decides that it needs a tool, kdeps runs the target resource. kdeps gives the result back to the LLM, and the LLM continues. The LLM sees only the output of the tool. It does not see the resource YAML.

This page covers tools: on a chat: resource. A chat with loop: also gets the built-in tools.

chat resource receives promptLLM: 'I need to calculate something'resource: calcTooltool args become get('expression')LLM: 'The answer is 42'final responsecalls tool 'calculate'output returned to LLM
yaml
# resources/chat.yaml
chat:
  context:
    prompt: "{{ get('q') }}"
  tools:
    list:
      - name: calculate
        description: Perform mathematical calculations  # LLM uses this to decide when to call
        script: calcTool                                # actionId of the resource to run
        parameters:
          expression:
            type: string
            description: Math expression to evaluate
            required: true

Tool definition ​

yaml
# resources/example.yaml
tools:
  - name: tool_name           # must be unique within this chat resource
    description: What it does # the LLM reads this to decide when to call it
    script: resourceId        # actionId of the resource that executes the tool
    parameters:               # inputs the LLM must supply
      param_name:
        type: string          # string, number, integer, boolean, object, array
        description: What this parameter is for
        required: true

Tool types ​

Resource-based tools ​

Tools that reference other kdeps resources:

yaml
# The tool resource
actionId: calcTool
component:
  name: python
  with:
    script: |
      import json
      import math
      expr = """{{ get('expression') }}"""
      result = eval(expr, {"__builtins__": {}, "math": math})
      print(json.dumps({"result": result}))

---
# The LLM that uses the tool
actionId: llmWithTools
chat:
  context:
    prompt: "{{ get('q') }}"
  tools:
    list:
      - name: calculate
        description: Evaluate mathematical expressions
        script: calcTool
        parameters:
          expression:
            type: string
            description: "Math expression (e.g., '2 + 2', 'math.sqrt(16)')"
            required: true

External MCP tools ​

Use mcp: instead of script: to call a tool on an external MCP server. kdeps spawns the server as a subprocess, performs the JSON-RPC initialize handshake, calls the tool, and shuts the process down.

yaml
# resources/example.yaml
tools:
  - name: tool_name
    description: What it does
    mcp:
      server: npx
      args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
      transport: stdio        # only "stdio" supported (default)
      env:
        HOME: /tmp
    parameters:
      path:
        type: string
        description: File path
        required: true
FieldTypeDescription
serverstringExecutable to start the MCP server (e.g. npx, uvx, /usr/bin/my-mcp)
argslistArguments passed to the executable
transportstringTransport type - stdio (default)
envmapExtra environment variables injected into the subprocess

mcp: and script: are mutually exclusive. kdeps starts a new subprocess for each tool call.

Example - filesystem access with npx:

yaml
# resources/example.yaml
chat:
  context:
    prompt: "{{ get('q') }}"
  tools:
    list:
      - name: read_file
        description: Read the contents of a file
        mcp:
          server: npx
          args: ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"]
        parameters:
          path:
            type: string
            description: Absolute path of the file to read
            required: true

Multiple tools ​

Define multiple tools for different capabilities:

yaml
# resources/example.yaml
chat:
  context:
    prompt: "{{ get('q') }}"
  tools:
    list:
      - name: calculate
        description: Perform math calculations
        script: calcTool
        parameters:
          expression:
            type: string
            required: true

      - name: search_database
        description: Search the product database
        script: dbSearchTool
        parameters:
          query:
            type: string
            description: Search query
            required: true
          category:
            type: string
            description: Product category filter
            required: false
          limit:
            type: integer
            description: Maximum results
            required: false

      - name: send_email
        description: Send an email notification
        script: emailTool
        parameters:
          to:
            type: string
            required: true
          subject:
            type: string
            required: true
          body:
            type: string
            required: true

Parameter types ​

TypeDescriptionExample
stringText value"hello"
numberFloat/decimal3.14
integerWhole number42
booleanTrue/falsetrue
objectJSON object{"key": "value"}
arrayList of values[1, 2, 3]

Tool execution flow ​

User Prompt
    v
LLM analyzes prompt
    v
LLM decides to call tool(s)
    v
kdeps executes tool resource
    v
Tool result returned to LLM
    v
LLM generates final response

Use cases ​

  • Let the model do math, run code, or query a database during a response. Then it does not guess (script: points to a component call such as python or exec).
  • Give the model read access to a filesystem, an API, or another service through an external MCP server (mcp:).
  • Chain capabilities: the model calls web_search, then web_scraper on a result, then summarizes - each tool is a resource the model invokes on demand.

See also ​

kdeps has the Apache 2.0 License.