mcptracker

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package mcptracker is the mcp tracker provider (ADR-003): a tracker whose system has an MCP server, such as JIRA Cloud or Data Center, read and written by calling the server's tools directly. No model is involved, so what it reads is as deterministic as a REST call, and it calls with ynf's own credentials, never the agent's.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Tool string         `json:"tool"`
	Args map[string]any `json:"args"`
}

Call is a tool and its arguments. In arguments, a string that is exactly {add}, {remove} or {labels} becomes that list; {key} and {text} are replaced inside any string.

type Config

type Config struct {
	Provider string `json:"provider"`
	// Site is the tracker's web address; its host names the tracker in item keys.
	Site   string `json:"site"`
	Server struct {
		// Command starts a server that speaks MCP on stdin and stdout; it receives only the
		// variables named in Env, and PATH and HOME.
		Command []string `json:"command"`
		Env     []string `json:"env"`
		// URL is a server reached over HTTP; TokenEnv names the variable holding its bearer token.
		URL      string `json:"url"`
		TokenEnv string `json:"token_env"`
	} `json:"server"`
	Get     Call `json:"get"`
	Comment Call `json:"comment"`
	Label   Call `json:"label"`
	// Fields are CEL over the get tool's result, bound to result: title, body, labels (a list of
	// strings), status, repo, the repository the ticket says its code goes to, if any, and
	// comments, the text of each of the ticket's comments, if mapped: it is how a retried step
	// finds the marker of a comment already posted.
	Fields struct {
		Title    string `json:"title"`
		Body     string `json:"body"`
		Labels   string `json:"labels"`
		Status   string `json:"status"`
		Repo     string `json:"repo"`
		Comments string `json:"comments"`
	} `json:"fields"`
	// ClosedWhen is CEL over status and labels; true means the ticket is closed.
	ClosedWhen string `json:"closed_when"`
}

Config is an mcp tracker as factory.yaml declares it.

func Parse

func Parse(m map[string]any) (Config, error)

Parse reads a factory.yaml tracker entry.

type Tracker

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

Tracker is an mcp tracker. It connects on first use and keeps the session.

func New

func New(c Config) (*Tracker, error)

New builds the tracker, compiling its mappings so a mistake shows when the factory is read.

func (*Tracker) Check

func (t *Tracker) Check(ctx context.Context) error

Check connects to the tracker's server and confirms it has every tool the tracker is configured to call, so a mistyped tool name shows before any ticket is started.

func (*Tracker) Close

func (t *Tracker) Close() error

Close ends the session, and with a command, the server.

func (*Tracker) Comment

func (t *Tracker) Comment(ctx context.Context, key, marker, body string) error

Comment implements tracker.Tracker. The marker goes in the comment. With fields.comments mapped, the comment is posted only if no existing one contains the marker, so a retried step does not comment twice; without it there is no way to know, and it is always posted.

func (*Tracker) Get

func (t *Tracker) Get(ctx context.Context, key string) (facts.Ticket, tracker.Text, error)

Get implements tracker.Tracker.

func (*Tracker) Host

func (t *Tracker) Host() string

Host is the tracker's host, as item keys name it.

func (*Tracker) Label

func (t *Tracker) Label(ctx context.Context, key string, add, remove []string) error

Label implements tracker.Tracker: {labels} is the ticket's labels after the change, for a tool that sets them all; {add} and {remove} are for one that changes them.

func (*Tracker) WithTransport

func (t *Tracker) WithTransport(dial func() mcp.Transport) *Tracker

WithTransport makes the tracker connect through the transport a call to dial gives, instead of its configured server: for tests.

Jump to

Keyboard shortcuts

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