mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
* Add MCP server endpoint for external AI assistants Expose Sure's Assistant::Function tools via JSON-RPC 2.0 at POST /mcp, enabling external AI clients (Claude, GPT, etc.) to query financial data through the Model Context Protocol. - Bearer token auth via MCP_API_TOKEN / MCP_USER_EMAIL env vars - JSON-RPC 2.0 with proper id threading, notification handling (204) - Transient session (sessions.build) to prevent impersonation leaks - Centralize function_classes in Assistant module - Docker Compose example with Pipelock forward proxy - 18 integration tests with scoped env (ClimateControl) * Update compose for full Pipelock MCP reverse proxy integration Use Pipelock's --mcp-listen/--mcp-upstream flags (PR #127) to run bidirectional MCP scanning in the same container as the forward proxy. External AI clients connect to port 8889, Pipelock scans requests (DLP, injection, tool policy) and responses (injection, tool poisoning) before forwarding to Sure's /mcp endpoint. This supersedes the standalone compose in PR #1050. * Fix compose --preset→--mode, add port 3000 trust comment, notification test Review fixes: - pipelock run uses --mode not --preset (would prevent stack startup) - Document port 3000 exposes /mcp directly (auth still required) - Add version requirement note for Pipelock MCP listener support - Add test: tools/call sent as notification does not execute
44 lines
973 B
Ruby
44 lines
973 B
Ruby
module Assistant
|
|
Error = Class.new(StandardError)
|
|
|
|
REGISTRY = {
|
|
"builtin" => Assistant::Builtin,
|
|
"external" => Assistant::External
|
|
}.freeze
|
|
|
|
class << self
|
|
def for_chat(chat)
|
|
implementation_for(chat).for_chat(chat)
|
|
end
|
|
|
|
def config_for(chat)
|
|
raise Error, "chat is required" if chat.blank?
|
|
Assistant::Builtin.config_for(chat)
|
|
end
|
|
|
|
def available_types
|
|
REGISTRY.keys
|
|
end
|
|
|
|
def function_classes
|
|
[
|
|
Function::GetTransactions,
|
|
Function::GetAccounts,
|
|
Function::GetHoldings,
|
|
Function::GetBalanceSheet,
|
|
Function::GetIncomeStatement,
|
|
Function::ImportBankStatement,
|
|
Function::SearchFamilyFiles
|
|
]
|
|
end
|
|
|
|
private
|
|
|
|
def implementation_for(chat)
|
|
raise Error, "chat is required" if chat.blank?
|
|
type = chat.user&.family&.assistant_type.presence || "builtin"
|
|
REGISTRY.fetch(type) { REGISTRY["builtin"] }
|
|
end
|
|
end
|
|
end
|