Conversation
|
This PR introduces comprehensive support for MCP (Model Context Protocol) analytics records within Tyk Pump. It enables the processing, storage, and aggregation of analytics for MCP-based APIs by adding new data structures, a dedicated aggregation pipeline, and support across all major storage backends. Files Changed AnalysisThis is a significant feature addition, reflected in the 30 files changed with 4,168 additions and only 147 deletions. The changes are predominantly additive, indicating new functionality.
Architecture & Impact AssessmentWhat this PR accomplishesThis PR enables Tyk Pump to process a new type of analytics record generated by MCP-based APIs. Previously, the pump was limited to REST and GraphQL analytics. This change provides feature parity for analytics collection for this new API protocol, allowing operators to monitor MCP API traffic, performance, and errors. Key technical changes introduced
Affected system components
Component Interaction Flowgraph TD
subgraph Tyk Gateway
A[Gateway generates AnalyticsRecord]
end
subgraph Tyk Pump
A --> B{Pump receives records}
B --> C{"record.IsMCPRecord()?"}
C -- Yes --> D[MCP Analytics Pipeline]
C -- No --> E[Standard REST/GraphQL Pipeline]
subgraph D [MCP Analytics Pipeline]
direction LR
D_Agg(AggregateMCPData) --> D_MongoAgg[MCPMongoAggregatePump]
D_Agg --> D_SQLAgg[MCPSQLAggregatePump]
D_Agg --> D_Hybrid[HybridPump]
D_Raw(Store Raw MCP Data) --> D_Mongo[MCPMongoPump]
D_Raw --> D_SQL[MCPSQLPump]
D_Raw --> D_ES[ElasticsearchPump]
end
end
subgraph Storage Backends
D_MongoAgg & D_Mongo --> DB1[MongoDB]
D_SQLAgg & D_SQL --> DB2[SQL Database]
D_ES --> DB3[Elasticsearch]
D_Hybrid --> DB4[MDCB]
end
Scope Discovery & Context Expansion
Metadata
Powered by Visor from Probelabs Last updated: 2026-04-17T08:03:33.319Z | Triggered by: pr_updated | Commit: 98ca874 💡 TIP: You can chat with Visor using |
Security Issues (1)
Security Issues (1)
Performance Issues (2)
Quality Issues (1)
Powered by Visor from Probelabs Last updated: 2026-04-17T08:02:49.324Z | Triggered by: pr_updated | Commit: 98ca874 💡 TIP: You can chat with Visor using |
e094776 to
f1ccfcb
Compare
… and elasticsearch
f1ccfcb to
1ec8a10
Compare
| mcpOnly: true, | ||
| } | ||
|
|
||
| p.allMetrics = append(p.allMetrics, totalStatusMetric, pathStatusMetrics, keyStatusMetrics, oauthStatusMetrics, totalLatencyMetrics, mcpCallsMetric, mcpLatencyMetric) |
There was a problem hiding this comment.
I wouldn't add this as a default metric
There was a problem hiding this comment.
so what you're saying is to only append to slice if the mcp logic is enabled?
There was a problem hiding this comment.
I'm saying is not to add this as a default prometheus metric (https://github.com/TykTechnologies/tyk-pump?tab=readme-ov-file#prometheus) but document + expose McpOnly in a configuration so users can set their custom metrics around it (https://github.com/TykTechnologies/tyk-pump?tab=readme-ov-file#custom-prometheus-metrics).
The current problem with default metrics is that users cannot modify them and they need to use extra steps ( e.g. TYK_PMP_PUMPS_PROMETHEUS_META_DISABLEDMETRICS) to disable them if not needed.
I'd make it simple here and expose + document with some example.
|
|
||
| // mcpOnly marks a metric as MCP-specific: it is only processed for records where IsMCPRecord() is true. | ||
| // This is an internal field and is not user-configurable. | ||
| mcpOnly bool |
There was a problem hiding this comment.
Maybe this should be a public config so user can set their custom metric around mcp.
There was a problem hiding this comment.
can you please explain what is the end goal here?
🚨 Jira Linter FailedCommit: The Jira linter failed to validate your PR. Please check the error details below: 🔍 Click to view error detailsNext Steps
This comment will be automatically deleted once the linter passes. |
…y_breakdown options
…d latency_breakdown options" This reverts commit 9f340b3b31019492f43b18dc1550513048cef6a5.
MCPSQLAggregatePump was only calling AutoMigrate without creating the (dimension, timestamp, org_id, dimension_value) composite index that SQLAggregatePump creates for tyk_aggregated. Without this index all MCP analytics SQL queries perform full table scans. Adds ensureTable and ensureIndex methods matching the regular aggregate pump, including PostgreSQL CONCURRENTLY support and the omit_index_creation config flag.
MCPSQLAggregatePump was not migrating existing sharded tables on startup, unlike SQLAggregatePump which calls HandleTableMigration and MigrateAllShardedTables. If the schema changes, existing shards would not be updated.
…ate-mcp-analytics # Conflicts: # .github/workflows/ci-test.yml
|


Extends pump support to handle MCP (Model Context Protocol) analytics records across all major storage backends.
Changes