[TT-16489] Created MCP definition ground work - #7696
Conversation
|
This PR introduces the foundational data structures for Model Context Protocol (MCP) APIs. It extends the core API definition and the OpenAPI (OAS) specification to enable the configuration of MCP APIs, ensuring full backward compatibility with existing definitions. Files Changed Analysis
Architecture & Impact Assessment
OAS to Classic API Definition Flow: graph TD
A["OAS Definition with x-tyk-api-gateway"] -- contains --> B{"mcpTools, mcpResources, or mcpPrompts"};
B -- is processed by --> C["OAS Importer (middleware.ExtractTo)"];
C -- if MCP section exists --> D["api.MarkAsMCP()"];
D -- sets fields on --> E["Classic APIDefinition (ApplicationProtocol='mcp', JsonRpcVersion='2.0')"];
Scope Discovery & Context Expansion
Metadata
Powered by Visor from Probelabs Last updated: 2026-01-26T16:08:29.528Z | Triggered by: pr_updated | Commit: 205d10c 💡 TIP: You can chat with Visor using |
Security Issues (1)
Architecture Issues (1)
✅ Performance Check PassedNo performance issues found – changes LGTM. ✅ Quality Check PassedNo quality issues found – changes LGTM. Powered by Visor from Probelabs Last updated: 2026-01-26T16:08:32.846Z | Triggered by: pr_updated | Commit: 205d10c 💡 TIP: You can chat with Visor using |
|
API Changes --- prev.txt 2026-01-26 16:08:07.332218228 +0000
+++ current.txt 2026-01-26 16:07:57.448293984 +0000
@@ -84,6 +84,12 @@
OAuthAuthorizationTypeClientCredentials = "clientCredentials"
// OAuthAuthorizationTypePassword is the authorization type for password flow.
OAuthAuthorizationTypePassword = "password"
+
+ // JSON-RPC protocol versions
+ JsonRPC20 = "2.0"
+
+ // Application protocols
+ AppProtocolMCP = "mcp"
)
const (
GraphQLEngineDataSourceKindREST = "REST"
@@ -184,6 +190,8 @@
ListenPort int `bson:"listen_port" json:"listen_port"`
Protocol string `bson:"protocol" json:"protocol"`
EnableProxyProtocol bool `bson:"enable_proxy_protocol" json:"enable_proxy_protocol"`
+ JsonRpcVersion string `bson:"json_rpc_version,omitempty" json:"json_rpc_version,omitempty"`
+ ApplicationProtocol string `bson:"application_protocol,omitempty" json:"application_protocol,omitempty"`
APIID string `bson:"api_id" json:"api_id"`
OrgID string `bson:"org_id" json:"org_id"`
UseKeylessAccess bool `bson:"use_keyless" json:"use_keyless"`
@@ -338,6 +346,13 @@
hierarchy. A child API is identified by having a BaseID that differs from
its own APIID.
+func (a *APIDefinition) IsMCP() bool
+ IsMCP returns true if this API uses the Model Context Protocol.
+
+func (a *APIDefinition) MarkAsMCP()
+ MarkAsMCP configures the API definition as a Model Context Protocol (MCP)
+ API.
+
func (a *APIDefinition) Migrate() (versions []APIDefinition, err error)
func (a *APIDefinition) MigrateAuthentication()
@@ -352,6 +367,9 @@
SetDisabledFlags set disabled flags to true, since by default they are not
enabled in OAS API definition.
+func (a *APIDefinition) SetProtocol(transport, application string)
+ SetProtocol configures the transport and application protocol for the API.
+
type AnalyticsPluginConfig struct {
// Enabled activates the custom plugin
Enabled bool `bson:"enable" json:"enable,omitempty"`
@@ -3698,6 +3716,15 @@
// Operations contains configuration for middleware that can be applied to individual endpoints within the API (per-endpoint).
Operations Operations `bson:"operations,omitempty" json:"operations,omitempty"`
+
+ // McpTools contains configuration for middleware that can be applied to MCP tools.
+ McpTools map[string]*Operation `bson:"mcpTools,omitempty" json:"mcpTools,omitempty"`
+
+ // McpResources contains configuration for middleware that can be applied to MCP resources.
+ McpResources map[string]*Operation `bson:"mcpResources,omitempty" json:"mcpResources,omitempty"`
+
+ // McpPrompts contains configuration for middleware that can be applied to MCP prompts.
+ McpPrompts map[string]*Operation `bson:"mcpPrompts,omitempty" json:"mcpPrompts,omitempty"`
}
Middleware holds configuration for Tyk's native middleware.
|
ceba416 to
dc79af7
Compare
aef6d45 to
711180d
Compare
5cbf6cd to
c08858c
Compare
e231f92 to
da5b67a
Compare
a76a065 to
e547770
Compare
|



MCP Definition Structure
Ticket Details
TT-16489
Generated at: 2026-01-26 18:18:01