mcpsetup

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mcpsetup derives the hosted PromptVM MCP endpoint from the API base URL and writes/prints per-client MCP configuration (Claude Code, Codex CLI).

The snippet formats follow the frontend's src/lib/mcp/client-snippets.ts so every surface (web app, CLI, docs) shows equivalent configuration; header auth uses the MCP server's direct pk/sk bearer envelope (`Authorization: Bearer pvm_mcp_pkv1_<base64url(pk:sk)>`, see the frontend's src/lib/mcp/pksk-encoder.ts and the MCP contracts' PKSK_BEARER_PREFIX).

Index

Constants

View Source
const EnvMCPURL = "PROMPTVM_MCP_URL"

EnvMCPURL overrides the derived MCP endpoint.

View Source
const PKSKBearerPrefix = "pvm_mcp_pkv1_"

PKSKBearerPrefix is the MCP server's direct pk/sk bearer envelope prefix (cross-repo contract: mcp packages/contracts PKSK_BEARER_PREFIX, frontend src/lib/mcp/pksk-encoder.ts).

Variables

This section is empty.

Functions

func ClaudeAddCommand

func ClaudeAddCommand(endpoint, scope string) []string

ClaudeAddCommand renders the Claude Code CLI registration command (format: client-snippets.ts `claude-code` OAuth snippet). scope is passed through explicitly — `claude mcp add` defaults to its private "local" scope, so omitting --scope for project installs would NOT register the shared, committed project scope the .mcp.json fallback writes.

func ClaudeMCPJSON

func ClaudeMCPJSON(endpoint string) string

ClaudeMCPJSON renders the project-level .mcp.json server entry used when the `claude` binary is not available (format: client-snippets.ts `generic-json`).

func ClaudeSnippet

func ClaudeSnippet(endpoint string) string

ClaudeSnippet is the copy-paste form of the Claude Code registration command.

func CodexSnippet

func CodexSnippet(endpoint string, headers map[string]string) string

CodexSnippet renders the ~/.codex/config.toml block (format: client-snippets.ts `codex-cli`). headers, when non-nil, are emitted as a `[mcp_servers.promptvm.headers]` table, matching the manual-token snippet shape.

func DeriveMCPURL

func DeriveMCPURL(apiBaseURL string) string

DeriveMCPURL maps a PromptVM API base URL to its hosted MCP endpoint. The hosted server serves the streamable-HTTP protocol only at the /mcp path (everything else 404s), so the derived URL always carries it:

https://dev-api.promptvm.ai     → https://dev-mcp.promptvm.ai/mcp
https://staging-api.promptvm.ai → https://staging-mcp.promptvm.ai/mcp
https://api.promptvm.ai        → https://mcp.promptvm.ai/mcp

Returns "" when no mapping applies (e.g. localhost) so callers can require an explicit --mcp-url / PROMPTVM_MCP_URL (documented as the full endpoint, path included).

func ExistingCodexAuthorization

func ExistingCodexAuthorization(existing []byte) string

ExistingCodexAuthorization returns the Authorization header of an existing [mcp_servers.promptvm.headers] table when it already carries a usable MCP pk/sk bearer ("Bearer pvm_mcp_pkv1_…"), or "" otherwise. Used to keep an already-working credential across re-runs instead of minting a new key.

func MergeCodexConfig

func MergeCodexConfig(existing []byte, endpoint string, headers map[string]string) ([]byte, error)

MergeCodexConfig merges the promptvm MCP server entry into an existing ~/.codex/config.toml document (existing may be nil/empty for a fresh file). The merge is textual — comments, blank lines, key ordering, and formatting of all other content are preserved byte-for-byte. An existing [mcp_servers.promptvm] table (and its subtables) is removed and the fresh snippet is appended. headers, when non-nil, become [mcp_servers.promptvm.headers].

func PkSkAuthorization

func PkSkAuthorization(publicKey, secretKey string) string

PkSkAuthorization packs an API key pair into the only header form the hosted MCP server authenticates: "Bearer pvm_mcp_pkv1_<base64url(pk:sk)>" (base64url, no padding — the server tolerates padding but the contract encoder omits it).

func ResolveMCPURL

func ResolveMCPURL(flagValue, apiBaseURL string) (string, error)

ResolveMCPURL resolves the MCP endpoint with the standard precedence: explicit flag value → PROMPTVM_MCP_URL env → derivation from the API base URL. Returns an error when nothing resolves.

Types

This section is empty.

Jump to

Keyboard shortcuts

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