tools

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package tools holds MCP tool registrations. Each resource type lives in its own file (deals.go, persons.go, ...) and exposes a Register function that the server's startup wires up.

Every tool is added to *both* the SDK (via mcp.AddTool) and the registry below. The registry powers the `pipedrive-mcp --dump-schemas` flag, which produces the deterministic JSON the schema-diff CI gate compares against the previous release tag.

The MCP Go SDK does not expose a public Server.Tools() to walk registered tools, so this parallel registry is the workaround. If a future SDK version ships ListTools(), drop this and switch.

Index

Constants

View Source
const SDKVersion = "v1.5.0"

SDKVersion is recorded in the schema dump header so a diff caused by an SDK upgrade can be classified as PATCH rather than as a breaking surface change. Update in lockstep with the go.mod pin.

Variables

View Source
var Default = New()

Default is the process-wide registry. Phase 1+ tool packages call Default.Add after mcp.AddTool.

Functions

func Add

func Add(t *mcp.Tool)

Add records a tool in the process-wide Default registry.

func AddTool

func AddTool[In, Out any](s *mcp.Server, t *mcp.Tool, h mcp.ToolHandlerFor[In, Out])

AddTool registers a tool with the MCP server AND records it in the process-wide Default registry. Schemas are inferred and assigned before mcp.AddTool runs so --dump-schemas (and the schema-diff CI gate) see the same shapes the live server validates against — the SDK copies *t internally and mutates the copy, so a bare *t in our registry would otherwise expose empty schemas.

func DumpJSON

func DumpJSON(w io.Writer, binaryVersion string) error

DumpJSON writes the process-wide Default registry as JSON.

func RegisterActivities

func RegisterActivities(s *mcp.Server, c activitiesClient, companyDomain string, opts RegisterOptions)

RegisterActivities wires get_activity, list_activities, and create_activity into the MCP server. opts.DryRun, when true, makes create_activity return a synthetic preview without firing the upstream POST.

func RegisterCache

func RegisterCache(s *mcp.Server, c cacheClient)

RegisterCache wires the refresh_field_cache tool into the MCP server. The tool has no inputs — it always refreshes all three per-resource caches (deals, persons, organizations) in parallel. Activities don't have a custom-field cache on Pipedrive v2 so they are intentionally absent.

func RegisterDeals

func RegisterDeals(s *mcp.Server, c dealsClient, companyDomain string, opts RegisterOptions)

RegisterDeals wires get_deal, list_deals, and create_deal into the MCP server. opts.DryRun, when true, makes create_deal return a synthetic preview without firing the upstream POST.

func RegisterNotes

func RegisterNotes(s *mcp.Server, c notesClient, opts RegisterOptions)

RegisterNotes wires the notes tools into the MCP server.

Reads (get_note, list_notes) and the create write tool always register. delete_note is destructive and registers ONLY when opts.EnableDestructive is true (per CLAUDE.md hard rule #3 — server-build-time gating, not annotation-based).

opts.DryRun, when true, makes create_note and delete_note return synthetic previews without firing the upstream POST/DELETE.

func RegisterOrganizations

func RegisterOrganizations(s *mcp.Server, c organizationsClient, companyDomain string, opts RegisterOptions)

RegisterOrganizations wires get_organization, list_organizations, and create_organization into the MCP server. opts.DryRun, when true, makes create_organization return a synthetic preview without firing the upstream POST.

func RegisterPersons

func RegisterPersons(s *mcp.Server, c personsClient, companyDomain string, opts RegisterOptions)

RegisterPersons wires get_person, list_persons, and create_person into the MCP server. opts.DryRun, when true, makes create_person return a synthetic preview without firing the upstream POST.

func RegisterPipelines

func RegisterPipelines(s *mcp.Server, c pipelinesClient, companyDomain string)

RegisterPipelines wires list_pipelines and list_stages into the MCP server. The companyDomain is needed for URL injection on outputs; pass cfg.CompanyDomain from the server constructor.

func RegisterSearch

func RegisterSearch(s *mcp.Server, c searchClient)

RegisterSearch wires the search tool into the MCP server.

Types

type RegisterOptions added in v0.2.0

type RegisterOptions struct {
	DryRun            bool // mirrors PIPEDRIVE_DRY_RUN
	EnableDestructive bool // mirrors PIPEDRIVE_ENABLE_DESTRUCTIVE
}

RegisterOptions bundles the server-wide flags every Register function for a write-bearing resource takes. Bundling stops a future caller from swapping `DryRun` and `EnableDestructive` positionally — both type-check, both look fine in code review.

Both fields gate *registration*: when EnableDestructive is false, destructive tools (currently only `delete_note`) don't register at all. Per CLAUDE.md hard rule #3, that's server-build-time gating, not annotation-based — flipping it requires a server restart.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry tracks every tool added via Register/Add for the schema dump. Tests construct a fresh Registry; the process-wide registration uses Default.

func New

func New() *Registry

New returns an empty Registry.

func (*Registry) Add

func (r *Registry) Add(t *mcp.Tool)

Add records a tool. Call after a successful mcp.AddTool.

func (*Registry) DumpJSON

func (r *Registry) DumpJSON(w io.Writer, binaryVersion string) error

DumpJSON writes the registered tools as deterministic JSON. Tools are sorted alphabetically by name. The header records the SDK version and the binary version (passed in by the caller — usually internal/version.Version).

Jump to

Keyboard shortcuts

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