Class: AnalyticsOps::MCPServer
- Inherits:
-
Object
- Object
- AnalyticsOps::MCPServer
- Includes:
- CustomReportTool, DiscoveryTools, ExperimentalTools, HealthTools, OverviewTools, StandardReportTool
- Defined in:
- lib/analytics_ops/mcp_server.rb,
lib/analytics_ops/mcp_server/health_tools.rb,
lib/analytics_ops/mcp_server/overview_tools.rb,
lib/analytics_ops/mcp_server/discovery_tools.rb,
lib/analytics_ops/mcp_server/custom_report_tool.rb,
lib/analytics_ops/mcp_server/experimental_tools.rb,
lib/analytics_ops/mcp_server/standard_report_tool.rb,
sig/analytics_ops.rbs
Overview
Strictly read-only MCP bridge for ChatGPT, Codex, Claude, and other MCP clients.
Defined Under Namespace
Modules: CustomReportTool, DiscoveryTools, ExperimentalTools, HealthTools, OverviewTools, StandardReportTool
Constant Summary collapse
- PROFILE =
/\A[A-Za-z][A-Za-z0-9_]{0,63}\z/- CONNECTION =
/\A[A-Za-z][A-Za-z0-9_-]{0,63}\z/- CONTROL_CHARACTERS =
/[\u0000-\u001f\u007f]/- PROFILE_JSON_PATTERN =
"^[A-Za-z][A-Za-z0-9_]{0,63}$"- CONNECTION_JSON_PATTERN =
"^[A-Za-z][A-Za-z0-9_-]{0,63}$"- READ_ONLY_ANNOTATIONS =
{ title: "Read Google Analytics", read_only_hint: true, destructive_hint: false, idempotent_hint: true, open_world_hint: true }.freeze
- PROFILE_INPUT =
{ type: "object", additionalProperties: false, properties: { profile: { type: "string", pattern: PROFILE_JSON_PATTERN, description: "Optional Analytics Ops profile. Uses the locally selected profile when omitted." } } }.freeze
- PERIOD_PROPERTIES =
{ last_days: { type: "integer", minimum: 1, maximum: Reports::Period::MAX_DAYS, description: "Optional number of complete days ending yesterday." }, start_date: { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "Optional YYYY-MM-DD start date; requires end_date." }, end_date: { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "Optional YYYY-MM-DD end date; requires start_date." }, compare: { type: "boolean", description: "Also include the equally long preceding period." } }.freeze
- OBJECT_OUTPUT =
{ type: "object" }.freeze
- ARRAY_OUTPUT =
{ type: "array", items: { type: "object" } }.freeze
- STANDARD_REPORTS =
( Reports::Catalog.names.select { |name| Reports::Catalog.fetch(name).kind == "standard" } + Reports::Catalog.aliases.keys ).sort.freeze
Constants included from CustomReportTool
CustomReportTool::FIELD_PATTERN
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize(config: "config/analytics_ops.yml", profile: nil, connection: nil, store: ServiceAccount::Store.new, workspace_loader: nil, connection_loader: nil, service_account_loader: nil, portfolio_loader: nil, transport: :grpc, timeout: nil, logger: nil) ⇒ MCPServer
constructor
A new instance of MCPServer.
- #start ⇒ Object
Constructor Details
#initialize(config: "config/analytics_ops.yml", profile: nil, connection: nil, store: ServiceAccount::Store.new, workspace_loader: nil, connection_loader: nil, service_account_loader: nil, portfolio_loader: nil, transport: :grpc, timeout: nil, logger: nil) ⇒ MCPServer
Returns a new instance of MCPServer.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/analytics_ops/mcp_server.rb', line 64 def initialize(config: "config/analytics_ops.yml", profile: nil, connection: nil, store: ServiceAccount::Store.new, workspace_loader: nil, connection_loader: nil, service_account_loader: nil, portfolio_loader: nil, transport: :grpc, timeout: nil, logger: nil) @config = config @profile = profile @connection = connection @store = store @workspace_loader = workspace_loader || method(:load_workspace) @connection_loader = connection_loader || method(:load_connection) @service_account_loader = service_account_loader || ServiceAccount.method(:load) @portfolio_loader = portfolio_loader || method(:load_portfolio) @transport = transport @timeout = timeout @logger = logger validate_defaults! @server = build_server define_tools end |
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
62 63 64 |
# File 'lib/analytics_ops/mcp_server.rb', line 62 def server @server end |
Instance Method Details
#start ⇒ Object
84 85 86 |
# File 'lib/analytics_ops/mcp_server.rb', line 84 def start ::MCP::Server::Transports::StdioTransport.new(server).open end |