# Tool Contract Validator for AI Agents (`skilled_glee/tool-contract-validator`) Actor

An AI tool for agents and developers that checks AI-agent tool definitions (MCP, OpenAI, Anthropic) and reports every contract error with JSON Pointer paths. Pure code: no LLM, no network.

- **URL**: https://apify.com/skilled_glee/tool-contract-validator.md
- **Developed by:** [EchoEmpire Machine Foundry (EchoEmpire LLC)](https://apify.com/skilled_glee) (community)
- **Categories:** Developer tools, AI, Agents
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 tool validateds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Tool Contract Validator for AI Agents

Checks AI-agent tool definitions and reports every contract error before you ship them. It accepts MCP tools, OpenAI function/tool format, and Anthropic tool format. Validation is pure code: JSON parsing and JSON Schema meta-validation. No LLM, no network, and no proxy.

### Input

| Field | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `tools` | array (1–500), or an envelope object | — | yes | Tool definitions. Also accepts an MCP `tools/list` response or `{ "tools": [...] }`. |
| `format` | `auto` | `mcp` | `openai` | `anthropic` | `auto` | no | `auto` detects each tool individually. |
| `strict` | boolean | `false` | no | When `true`, style issues (missing or empty tool description, missing parameter descriptions, and similar) are reported as errors instead of warnings. |

If `tools` is missing, not an array (after unwrap), empty, or contains a non-object item, the run fails with a clean input error, writes no dataset items, and charges no events.

#### Input example

```json
{
  "tools": [
    {
      "name": "get_weather",
      "description": "Get current weather for a city.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "city": { "type": "string", "description": "City name" }
        },
        "required": ["city"]
      }
    }
  ],
  "format": "auto",
  "strict": false
}
```

OpenAI tools use `{ "type": "function", "function": { "name", "description", "parameters" } }`. Anthropic tools use `input_schema` instead of `inputSchema`. Mixed batches are allowed when `format` is `auto`.

### Output

The dataset has one item per tool plus one summary item.

Per-tool item:

- `type`: `"tool"`
- `index`, `name`, `detectedFormat` (`mcp`, `openai`, or `anthropic`)
- `valid` (boolean)
- `errors` and `warnings`: arrays of `{ "code", "path", "message" }`, where `path` is a JSON Pointer

Summary item:

- `type`: `"summary"`
- `toolsChecked`, `validCount`, `invalidCount`, `duplicateNames`
- `format`, `strict`, `envelope`, `durationMs`

#### Output example

For the input example above (a valid MCP tool):

```json
[
  {
    "type": "tool",
    "index": 0,
    "name": "get_weather",
    "detectedFormat": "mcp",
    "valid": true,
    "errors": [],
    "warnings": []
  },
  {
    "type": "summary",
    "toolsChecked": 1,
    "validCount": 1,
    "invalidCount": 0,
    "duplicateNames": [],
    "format": "auto",
    "strict": false,
    "envelope": null,
    "durationMs": 40
  }
]
```

`durationMs` varies by run. This example is from a real run of build 1.0.2.

### What is checked

- Name is present and matches `^[a-zA-Z0-9_-]{1,64}$`
- Names are unique in the batch (duplicates are flagged on each copy)
- Description is present: missing or empty is a **warning** by default, and an **error** when `strict` is `true`
- An input schema is present, is an object schema, and is valid JSON Schema (draft 2020-12 / 07)
- Every `required` key exists in `properties`
- `type` values are valid
- `enum` is non-empty
- `$ref` values resolve
- Format-specific wrapper fields are correct (`inputSchema` vs `parameters` vs `input_schema`)

### Pricing

Pay per event: **`tool-validated` at $0.001** per tool definition checked.

Runs that fail input validation are not charged this event. The Actor's default run size is 256 MB.

### Limits

- 1 to 500 tool definitions per run
- Default timeout 60 seconds, default memory 256 MB

### Privacy

This Actor uses limited permissions. It does not call the network to fetch or execute tools; it only inspects the definitions you pass in.

# Actor input Schema

## `tools` (type: `array,object,string,integer,number,boolean`):

Array of 1-500 tool definitions (MCP, OpenAI function/tool, or Anthropic tool format). Also accepts an MCP tools/list response ({"result":{"tools":\[...]}}) or {"tools":\[...]}.

## `format` (type: `string`):

Tool format. 'auto' detects each tool individually.

## `strict` (type: `boolean`):

Report style issues (e.g. parameters without descriptions) as errors instead of warnings.

## Actor input object example

```json
{
  "tools": [
    {
      "name": "get_weather",
      "description": "Get current weather for a city.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "city": {
            "type": "string",
            "description": "City name"
          }
        },
        "required": [
          "city"
        ]
      }
    }
  ],
  "format": "auto",
  "strict": false
}
```

# Actor output Schema

## `results` (type: `string`):

One item per tool checked, plus one summary item.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "tools": [
        {
            "name": "get_weather",
            "description": "Get current weather for a city.",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "city": {
                        "type": "string",
                        "description": "City name"
                    }
                },
                "required": [
                    "city"
                ]
            }
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("skilled_glee/tool-contract-validator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "tools": [{
            "name": "get_weather",
            "description": "Get current weather for a city.",
            "inputSchema": {
                "type": "object",
                "properties": { "city": {
                        "type": "string",
                        "description": "City name",
                    } },
                "required": ["city"],
            },
        }] }

# Run the Actor and wait for it to finish
run = client.actor("skilled_glee/tool-contract-validator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "tools": [
    {
      "name": "get_weather",
      "description": "Get current weather for a city.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "city": {
            "type": "string",
            "description": "City name"
          }
        },
        "required": [
          "city"
        ]
      }
    }
  ]
}' |
apify call skilled_glee/tool-contract-validator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,skilled_glee/tool-contract-validator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/84m4QKwgK0qF0sk3g/builds/evWIReyIXyXvpECWr/openapi.json
