Python tools

Define a typed Python function, save it to a server, and let MCP clients discover and call it.

Write a function

Open the server's Tools workspace and choose New tool. Each definition must contain one top-level Python function. Annotate every parameter and include a docstring; MCPKite uses the function signature and documentation to describe the tool and derive its input schema.

def greet(name: str) -> str:
    """Return a short greeting for a person."""
    return f"Hello, {name}!"

Keep arguments and results bounded and return values that your client can use. The operator configures source, input, output, concurrency, and execution-time limits.

Save and publish

Save a new function or select an existing tool to edit it. If the isolated runner is healthy, a saved tool is published to MCP clients. If it is unavailable in local backend-only development, tools remain unpublished drafts.

Use the editor's maximize control for a full-screen view. Closing it or pressing Escape preserves the current draft. Deleting a tool removes it from that server.

Use workspace values

Python tools can read the current workspace's values from the environment:

import os

def lookup_account(account_id: str) -> str:
    """Look up an account using the configured service."""
    api_key = os.environ["ACCOUNT_API_KEY"]
    # Use the configured service without returning the key.
    return f"Lookup requested for {account_id}"

Only values for the current workspace are sent to the isolated sandbox for each call. Updates apply to subsequent calls without a server restart. Never include a secret in a tool result, error message, or log. See Workspace variables and secrets.

Understand execution

Tool code does not execute in FastAPI or in the trusted runner process. Each invocation runs in a short-lived sandbox container with a non-root user, read-only root filesystem, no host mounts, no deployment credentials, dropped Linux capabilities, and configured CPU, memory, process, temporary storage, and time limits.

Public HTTP/HTTPS egress is available only through the per-call proxy, which rejects non-public destination addresses. Runtime package installation is not available. The runner has access to the Docker daemon socket and must remain trusted and unexposed; see Runtime trust boundaries.

Test a tool

  1. Save the function in the server's Tools workspace.
  2. Connect MCP Inspector or another client to the endpoint from the Connect view.
  3. Confirm that the tool appears in the client's tool list.
  4. Call it with valid, safe arguments matching its input schema and verify the returned result.

If it does not appear, verify the runner is healthy and check the endpoint path and access token. Avoid placing secret values in test arguments or output.