tools

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tools turns the operations of an OpenAPI document into MCP tool definitions: one operation becomes one tool. It records, for each tool argument, where it goes in the HTTP request, so a handler can rebuild the call later. The rules are in docs/SPEC.md, section 3.

Index

Constants

View Source
const LookupKeyArg = "idempotency_key"

LookupKeyArg is the argument of a lookup tool that takes the Idempotency-Key to search for.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arg

type Arg struct {
	In   Location
	Name string // the name in the request: the parameter or body field name
}

Arg binds one tool argument to its place in the HTTP request.

type Location

type Location string

Location says where a tool argument goes in the HTTP request.

const (
	InPath      Location = "path"
	InQuery     Location = "query"
	InHeader    Location = "header"
	InBodyField Location = "body-field" // a top-level field of a JSON object body
	InBody      Location = "body"       // the whole JSON body
)

Argument locations.

type Tool

type Tool struct {
	Def    *mcp.Tool
	Method string // upper case, e.g. "POST"
	Path   string // the path template, e.g. "/charges/{charge_id}"
	Args   map[string]Arg
	// Input is the resolved input schema, used to validate arguments before
	// any request is sent.
	Input *jsonschema.Resolved
	// Sensitive holds the names of fields whose values must never be
	// written to the audit log: those marked "format: password" or
	// "x-writgate-sensitive: true" anywhere in the request or response.
	Sensitive map[string]bool
	// Lookup is the read-only tool that finds this call's result by
	// Idempotency-Key when it is unknown, from "x-writgate-lookup". It is
	// called with the arguments the two tools share plus LookupKeyArg.
	// Empty when the operation names none.
	Lookup string
}

Tool is one operation served as an MCP tool.

func Build

func Build(doc *v3.Document) (tools []*Tool, warnings []string, err error)

Build maps every operation in doc to a tool. An operation writgate can't serve is skipped with a warning; a conflict that would make tool names ambiguous is an error.

func (*Tool) Destructive

func (t *Tool) Destructive() bool

Destructive reports whether the tool is in the policy group "destructive".

func (*Tool) Name

func (t *Tool) Name() string

Name is the tool's name.

func (*Tool) ReadOnly

func (t *Tool) ReadOnly() bool

ReadOnly reports whether the tool is in the policy group "readonly".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL