Expand description
MCP (Model Context Protocol) server implementation.
Speaks JSON-RPC 2.0 over stdin/stdout. AI coding assistants (Claude Code,
Cursor, etc.) connect to difflore mcp-server as an MCP stdio transport
to query team rules and historical review verdicts while generating code.
Structs§
- Hook
Rule Context - Injectable rule context produced by
fetch_relevant_rules_for_hook.
Functions§
- detect_
active_ model - Read the active agent model from the standard env vars Claude Code, Cursor and the Anthropic SDK populate. Returns the first non-empty match in priority order. Lower-cased so callers can do substring checks without re-normalising.
- fetch_
relevant_ rules_ for_ hook - Hook-path rule fetch. Returns rendered text + injection count without the JSON-RPC envelope so the hook shim (or any other in-process consumer) can pull rules in one function call.
- haiku_
auto_ disable_ active - True when (a) the active model resolves to haiku and (b) the user
hasn’t opted back in via
DIFFLORE_FORCE_RULES_ON_HAIKU. Exposed fordifflore doctorso it can report “auto-applied” instead of “recommended”. - is_
haiku_ model - True when the detected model id looks like a Haiku variant (any generation). Substring match keeps us forward-compatible with future haiku revs without a hard-coded list.
- origin_
to_ kind - Classify a skill’s
origincolumn into a timelinekind. The mapping is the same onerule_hits_by_originuses — one source of truth so the telemetry aggregate and the timeline stream stay aligned. - parse_
file_ patterns - Parse the JSON-encoded
file_patternscolumn into aVec<String>. Malformed / missing → empty vec. Matches the permissive behaviour ofretrieval::pattern_allows— a rule with a broken pattern list never disappears silently, it just shows up with no patterns in the index. - predict_
pr_ scope - Predict a PR’s likely edit scope from the local imported review corpus.
- predict_
pr_ scope_ for_ repos - Repo-scoped sibling of
predict_pr_scope. - run
- Run the MCP server event loop. Reads JSON-RPC messages line-by-line from stdin and writes responses to stdout. Runs until stdin is closed.