Skip to content
Back to skills

Tool Schema Builder

BSecurity

Convert standard code functions into JSON schema format for AI function calling.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
ai-agentstypescriptpythonnodeapi

Works with

  • api

Security analysis

B84/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 27, 2026

npx -y skills add RMAzrim/opencode-artes --skill tool-schema-builder --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tool Schema Builder?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Tool Schema Builder
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/rmazrim-tool-schema-builder/badge)](https://www.skillsdirectory.com/skills/rmazrim-tool-schema-builder)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: Tool Schema Builder
description: Convert standard code functions into JSON schema format for AI function calling.
metadata:
  source: skills/tool-schema-builder/tool-schema-builder.md
---

# Tool Schema Builder

## Prerequisites & Dependencies
- Python 3.10+ with `inspect` / Node 18+ for runtime introspection (JSDoc, TypeScript `reflect-metadata`)
- Optional converters: `pip install pydantic docstring-parser` or `npm i zod zod-to-json-schema`
- No API keys required; optionally a model endpoint for a smoke-test call

## Execution Steps
1. Extract the function name, signature (parameter names, types, defaults), and docstring summary/description.
2. Map language types to JSON Schema: `str→string`, `int/float→number|integer`, `bool→boolean`, `list→array`, `dict/TypedDict→object`, `Optional[X]` excluded from `required`.
3. Encode constraints: enums, min/max values, patterns; add a one-line action-oriented description with units and expected format for each parameter.
4. Wrap in the provider's tool-calling envelope: `"type": "function"`, `"function": { "name": "...", "description": "...", "parameters": { ... } }` with `$schema: https://json-schema.org/draft/07/schema` and `additionalProperties: false`.
5. Validate the generated schema against JSON Schema meta-schema; round-trip a sample payload to verify completeness.
6. Wire the dispatcher: parse model tool call, validate arguments against the schema, and invoke the underlying function with typed validation errors on mismatch.

```python
from pydantic import BaseModel, Field, TypeAdapter

def get_weather(city: str, units: str = "celsius") -> dict:
    """Return the current weather for a city."""

class GetWeather(BaseModel):
    """Return the current weather for a city."""
    city: str = Field(description="City name, e.g. 'Berlin'")
    units: str = Field(default="celsius", pattern="^(celsius|fahrenheit)$")

tool = {
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": GetWeather.__doc__,
        "parameters": TypeAdapter(GetWeather).json_schema(),
    },
}
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.