mcpserver

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package mcpserver is the local MCP server behind `audd mcp`. It speaks MCP over stdio and runs each tool as the matching audd command in the same process, so tools use the same token, profile, cache, limits, and stream store as the CLI.

Index

Constants

View Source
const Instructions = `` /* 906-byte string literal not displayed */

Instructions tell the client's model how to use the tools.

View Source
const NoConsentFlag = "--no-consent-prompt"

NoConsentFlag is the hidden billing flag that fails with instructions instead of opening a browser to approve payment access.

Variables

View Source
var Providers = []string{"apple_music", "spotify", "deezer", "musicbrainz"}

Providers are the valid values of recognize's "return".

View Source
var TokenRotateInstructions = map[string]any{
	"action_required": "Rotating the API token disables the current token at once, so only the user can do it. Ask them to run the command below in a terminal. If audd is signed in, it stores the new token for audd automatically; other places that use the old token need the new one.",
	"command":         "audd token rotate",
	"done":            false,
}

TokenRotateInstructions is what token_rotate returns.

Functions

func New

func New(opts Options) *mcp.Server

New returns the MCP server with every audd tool.

func Serve

func Serve(ctx context.Context, opts Options, in io.ReadCloser, out io.WriteCloser) error

Serve runs the server on in/out until the client disconnects or ctx ends.

Types

type Options

type Options struct {
	// Run executes audd commands. Required.
	Run Runner
	// Version is reported to clients.
	Version string
	// Stat checks local paths; defaults to os.Stat.
	Stat func(string) (os.FileInfo, error)
}

Options configure the server.

type Result

type Result struct {
	Stdout, Stderr []byte
	Exit           int
}

Result is the outcome of one in-process audd command.

type Runner

type Runner func(ctx context.Context, args []string) Result

Runner runs an audd command (arguments without the program name) with JSON output and no terminal.

type ToolError

type ToolError struct {
	Code      string `json:"code"`
	APICode   int    `json:"api_code,omitempty"`
	Message   string `json:"message"`
	Hint      string `json:"hint,omitempty"`
	Retryable bool   `json:"retryable"`
	Exit      int    `json:"exit_code"`
}

ToolError is a failed command as the tool reports it.

func (*ToolError) Error

func (e *ToolError) Error() string

Jump to

Keyboard shortcuts

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