mcp

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 17 Imported by: 0

README

MCP Adapter Boundary

internal/mcp implements the read-only MCP request handling over SQLite. Stdio is the default transport; HTTP mode is a minimal private-pilot transport wrapper around the same request handler.

Rules:

  • read from the SQLite store surfaces; do not call Gong directly
  • keep tools read-only
  • require --db at the cmd/gongmcp boundary
  • support MCP tool presets and allowlisting through gongmcp --tool-preset, GONGMCP_TOOL_PRESET, --tool-allowlist, or GONGMCP_TOOL_ALLOWLIST; when unset, stdio serves the full read-only catalog
  • require an explicit preset or allowlist for all HTTP deployments
  • generate tool schemas after server options are applied, so tools/list reflects the active allowlist and configured LimitPolicy
  • keep row caps configurable through LimitPolicy, GONGMCP_MAX_* env vars, and gongmcp --max-* flags, but hard-cap them in code
  • treat schema maximum as the configured ceiling; omitted limit values use the lower request defaults in limits.go unless the configured ceiling is lower
  • return cap-feedback envelopes only for capped high-volume row tools that hit their effective limit; other capped aggregate/config tools may keep their normal result shape
  • support private AI governance suppression through --ai-governance-config or GONGMCP_AI_GOVERNANCE_CONFIG; do not expose configured restricted names in MCP output, do not expose filtered-match counts, and require an explicit governance-compatible tool preset or allowlist
  • keep browser/session auth separate from agent-client auth
  • do not expose raw Gong API passthrough, arbitrary SQL, profile import, raw cached call JSON, or full transcript dumps
  • return transcript snippets only, not full transcript bodies
  • use search_transcripts_by_call_facts for scoped transcript evidence by date, lifecycle, scope, system, or direction; it may return bounded neighboring-segment excerpts, but must not return call IDs, titles, speaker IDs, or full transcript text
  • use search_transcript_quotes_with_attribution when business users need bounded quote evidence with available Account/Opportunity attribution; call IDs, call titles, Account names/websites, and Opportunity names/close dates/probabilities require explicit opt-in flags, transcript_status=missing must fail closed because quote search starts from cached transcript segments, and person/contact titles must be reported as unavailable when not present in the cache
  • control transcript evidence provenance with GONGMCP_TRANSCRIPT_EVIDENCE_PROVENANCE=redacted|alias|raw; redacted is default, alias returns stable call/speaker refs, and raw IDs still require explicit opt-in flags
  • keep profile-aware tools tied to imported SQLite profile state
  • return lifecycle source and profile provenance when profile-aware behavior is used
  • keep unmapped CRM field output redacted by default
  • treat search_crm_field_values as an explicit, bounded value lookup exception; call IDs are redacted unless include_call_ids=true, object IDs and names are always redacted, and value snippets plus call titles require include_value_snippets=true
  • keep summarize_scorecard_activity aggregate-only by default; do not return call IDs, scorecard IDs, user IDs, answer text, call titles, transcript snippets, emails, raw JSON, or raw activity payloads
  • serve profile-aware fact/lifecycle queries from the SQLite profile cache keyed by active profile and canonical hash; writable CLI commands warm it, and read-only MCP reports stale cache state instead of writing
  • keep summarize_call_facts on safe business grouping dimensions; directed CRM value lookup belongs in search_crm_field_values

Practical checks:

go run ./cmd/gongctl mcp tools
GONGMCP_MAX_SEARCH_RESULTS=250 go run ./cmd/gongctl mcp tool-info search_transcript_segments
go test -count=1 ./internal/mcp ./cmd/gongmcp

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BusinessAnalysisToolNames added in v0.3.2

func BusinessAnalysisToolNames() []string

func ExpandToolPreset added in v0.3.2

func ExpandToolPreset(name string) ([]string, error)

func ParseToolAllowlist added in v0.3.2

func ParseToolAllowlist(raw string) ([]string, error)

func ToolCatalogNames added in v0.3.2

func ToolCatalogNames() []string

func ValidateGovernanceAllowlist added in v0.3.2

func ValidateGovernanceAllowlist(allowlist []string) error

func WriteToolPresetCatalog added in v0.3.2

func WriteToolPresetCatalog(w io.Writer) error

Types

type LimitPolicy added in v0.3.3

type LimitPolicy struct {
	SearchResults        int `json:"search_results"`
	CRMFields            int `json:"crm_fields"`
	LateStageSignals     int `json:"late_stage_signals"`
	MissingTranscripts   int `json:"missing_transcripts"`
	OpportunitySummaries int `json:"opportunity_summaries"`
	CRMMatrixCells       int `json:"crm_matrix_cells"`
	LifecycleResults     int `json:"lifecycle_results"`
	LifecycleCRMFields   int `json:"lifecycle_crm_fields"`
	CallFactGroups       int `json:"call_fact_groups"`
	InventoryResults     int `json:"inventory_results"`
	BusinessAnalysisRows int `json:"business_analysis_rows"`
}

func DefaultLimitPolicy added in v0.3.3

func DefaultLimitPolicy() LimitPolicy

func LimitPolicyFromEnv added in v0.3.3

func LimitPolicyFromEnv(getenv func(string) string) (LimitPolicy, error)

func (LimitPolicy) BusinessAnalysisLimit added in v0.3.3

func (p LimitPolicy) BusinessAnalysisLimit(value int) int

func (LimitPolicy) LifecycleLimit added in v0.3.3

func (p LimitPolicy) LifecycleLimit(value int) int

func (LimitPolicy) MissingTranscriptLimit added in v0.3.3

func (p LimitPolicy) MissingTranscriptLimit(value int) int

func (LimitPolicy) Normalize added in v0.3.3

func (p LimitPolicy) Normalize() LimitPolicy

func (LimitPolicy) SearchLimit added in v0.3.3

func (p LimitPolicy) SearchLimit(value int) int

func (LimitPolicy) WithOverride added in v0.3.3

func (p LimitPolicy) WithOverride(field string, value int) (LimitPolicy, error)

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      any             `json:"id"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

type Server

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

func NewServer

func NewServer(store Store, name, version string) *Server

func NewServerWithOptions

func NewServerWithOptions(store Store, name, version string, opts ...ServerOption) *Server

func (*Server) Handle

func (s *Server) Handle(ctx context.Context, req Request) *response

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, r io.Reader, w io.Writer) error

func (*Server) ServeHTTP added in v0.3.0

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServerOption

type ServerOption func(*Server)

func WithGovernanceCheck added in v0.3.0

func WithGovernanceCheck(check func(context.Context) error) ServerOption

func WithLimitPolicy added in v0.3.3

func WithLimitPolicy(policy LimitPolicy) ServerOption

func WithSuppressedCallIDs added in v0.3.0

func WithSuppressedCallIDs(callIDs []string) ServerOption

func WithToolAllowlist

func WithToolAllowlist(names []string) ServerOption

func WithTranscriptEvidenceProvenance added in v0.3.3

func WithTranscriptEvidenceProvenance(provenance TranscriptEvidenceProvenance) ServerOption

type Store

type Store interface {
	SyncStatusSummary(ctx context.Context) (*sqlite.SyncStatusSummary, error)
	SearchCallsRaw(ctx context.Context, params sqlite.CallSearchParams) ([]json.RawMessage, error)
	GetCallDetail(ctx context.Context, callID string) (*sqlite.CallDetail, error)
	ListCRMObjectTypes(ctx context.Context) ([]sqlite.CRMObjectTypeSummary, error)
	ListCRMFields(ctx context.Context, objectType string, limit int) ([]sqlite.CRMFieldSummary, error)
	SearchCRMFieldValues(ctx context.Context, params sqlite.CRMFieldValueSearchParams) ([]sqlite.CRMFieldValueMatch, error)
	ListCRMIntegrations(ctx context.Context) ([]sqlite.CRMIntegrationRecord, error)
	ListCRMSchemaObjects(ctx context.Context, integrationID string) ([]sqlite.CRMSchemaObjectRecord, error)
	ListCRMSchemaFields(ctx context.Context, params sqlite.CRMSchemaFieldListParams) ([]sqlite.CRMSchemaFieldRecord, error)
	ListGongSettings(ctx context.Context, params sqlite.GongSettingListParams) ([]sqlite.GongSettingRecord, error)
	ListScorecards(ctx context.Context, params sqlite.ScorecardListParams) ([]sqlite.ScorecardSummary, error)
	GetScorecardDetail(ctx context.Context, scorecardID string) (*sqlite.ScorecardDetail, error)
	ScorecardActivityOverview(ctx context.Context, limit int) (*sqlite.ScorecardActivityOverview, error)
	ActiveBusinessProfile(ctx context.Context) (*sqlite.BusinessProfile, error)
	ListBusinessConcepts(ctx context.Context) ([]sqlite.BusinessConcept, error)
	ListUnmappedCRMFields(ctx context.Context, params sqlite.UnmappedCRMFieldParams) ([]sqlite.UnmappedCRMField, error)
	AnalyzeLateStageSignals(ctx context.Context, params sqlite.LateStageSignalParams) (*sqlite.LateStageSignalsReport, error)
	ListOpportunitiesMissingTranscripts(ctx context.Context, params sqlite.OpportunityMissingTranscriptParams) ([]sqlite.OpportunityMissingTranscriptSummary, error)
	SearchTranscriptSegmentsByCRMContext(ctx context.Context, params sqlite.TranscriptCRMSearchParams) ([]sqlite.TranscriptCRMSearchResult, error)
	SummarizeOpportunityCalls(ctx context.Context, params sqlite.OpportunityCallSummaryParams) ([]sqlite.OpportunityCallSummary, error)
	CRMFieldPopulationMatrix(ctx context.Context, params sqlite.CRMFieldPopulationMatrixParams) (*sqlite.CRMFieldPopulationMatrix, error)
	ListLifecycleBucketDefinitions(ctx context.Context) ([]sqlite.LifecycleBucketDefinition, error)
	ListLifecycleBucketDefinitionsWithSource(ctx context.Context, requested string) ([]sqlite.LifecycleBucketDefinition, *sqlite.ProfileQueryInfo, error)
	SummarizeCallsByLifecycle(ctx context.Context, params sqlite.LifecycleSummaryParams) ([]sqlite.LifecycleBucketSummary, error)
	SummarizeCallsByLifecycleWithSource(ctx context.Context, params sqlite.LifecycleSummaryParams) ([]sqlite.LifecycleBucketSummary, *sqlite.ProfileQueryInfo, error)
	SearchCallsByLifecycle(ctx context.Context, params sqlite.LifecycleCallSearchParams) ([]sqlite.LifecycleCallSearchResult, error)
	SearchCallsByLifecycleWithSource(ctx context.Context, params sqlite.LifecycleCallSearchParams) ([]sqlite.LifecycleCallSearchResult, *sqlite.ProfileQueryInfo, error)
	PrioritizeTranscriptsByLifecycle(ctx context.Context, params sqlite.LifecycleTranscriptPriorityParams) ([]sqlite.LifecycleTranscriptPriority, error)
	PrioritizeTranscriptsByLifecycleWithSource(ctx context.Context, params sqlite.LifecycleTranscriptPriorityParams) ([]sqlite.LifecycleTranscriptPriority, *sqlite.ProfileQueryInfo, error)
	CompareLifecycleCRMFields(ctx context.Context, params sqlite.LifecycleCRMFieldComparisonParams) (*sqlite.LifecycleCRMFieldComparison, error)
	SummarizeCallFacts(ctx context.Context, params sqlite.CallFactsSummaryParams) ([]sqlite.CallFactsSummaryRow, error)
	SummarizeCallFactsWithSource(ctx context.Context, params sqlite.CallFactsSummaryParams) ([]sqlite.CallFactsSummaryRow, *sqlite.ProfileQueryInfo, error)
	CallFactsCoverage(ctx context.Context) (*sqlite.CallFactsCoverage, error)
	SearchTranscriptSegments(ctx context.Context, query string, limit int) ([]sqlite.TranscriptSearchResult, error)
	SearchTranscriptSegmentsByCallFacts(ctx context.Context, params sqlite.TranscriptCallFactsSearchParams) ([]sqlite.TranscriptCallFactsSearchResult, error)
	SearchTranscriptQuotesWithAttribution(ctx context.Context, params sqlite.TranscriptAttributionSearchParams) ([]sqlite.TranscriptAttributionSearchResult, error)
	SearchBusinessAnalysisCalls(ctx context.Context, params sqlite.BusinessAnalysisCallSearchParams) (*sqlite.BusinessAnalysisCallSearchResult, error)
	SearchBusinessAnalysisEvidence(ctx context.Context, params sqlite.BusinessAnalysisEvidenceSearchParams) ([]sqlite.BusinessAnalysisEvidenceRow, error)
	SummarizeBusinessAnalysisDimension(ctx context.Context, params sqlite.BusinessAnalysisDimensionSummaryParams) ([]sqlite.BusinessAnalysisDimensionRow, error)
	FindCallsMissingTranscripts(ctx context.Context, limit int) ([]sqlite.MissingTranscriptCall, error)
	FindCallsMissingTranscriptsByFilters(ctx context.Context, params sqlite.MissingTranscriptSearchParams) ([]sqlite.MissingTranscriptCall, error)
}

type ToolInfo

type ToolInfo struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	InputSchema map[string]any `json:"input_schema"`
}

func FindTool

func FindTool(name string) (ToolInfo, bool)

func FindToolWithLimitPolicy added in v0.3.3

func FindToolWithLimitPolicy(name string, policy LimitPolicy) (ToolInfo, bool)

func ToolCatalog

func ToolCatalog() []ToolInfo

func ToolCatalogWithLimitPolicy added in v0.3.3

func ToolCatalogWithLimitPolicy(policy LimitPolicy) []ToolInfo

type ToolPresetInfo added in v0.3.2

type ToolPresetInfo struct {
	Name        string   `json:"name"`
	Aliases     []string `json:"aliases,omitempty"`
	Purpose     string   `json:"purpose"`
	Tools       []string `json:"tools"`
	ToolCount   int      `json:"tool_count"`
	Recommended string   `json:"recommended_for"`
}

func ToolPresetCatalog added in v0.3.2

func ToolPresetCatalog() []ToolPresetInfo

type TranscriptEvidenceProvenance added in v0.3.3

type TranscriptEvidenceProvenance string
const (
	TranscriptEvidenceRedacted TranscriptEvidenceProvenance = "redacted"
	TranscriptEvidenceAlias    TranscriptEvidenceProvenance = "alias"
	TranscriptEvidenceRaw      TranscriptEvidenceProvenance = "raw"
)

func ParseTranscriptEvidenceProvenance added in v0.3.3

func ParseTranscriptEvidenceProvenance(value string) (TranscriptEvidenceProvenance, error)

Jump to

Keyboard shortcuts

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