Create an MCP Proxy definition.
curl --request POST \
--url https://{tenant}/api/mcps \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"openapi": "3.0.3",
"info": {
"title": "MCP Proxy Sample",
"version": "1.0.0"
},
"paths": {},
"components": {},
"servers": [
{
"url": "/mcp-sample/"
}
],
"x-tyk-api-gateway": {
"info": {
"name": "mcp-sample",
"state": {
"active": true
}
},
"server": {
"listenPath": {
"strip": true,
"value": "/mcp-sample/"
},
"authentication": {
"enabled": true,
"securitySchemes": {
"authToken": {
"enabled": true
}
}
}
},
"upstream": {
"url": "http://localhost:7878/mcp"
},
"middleware": {
"global": {
"contextVariables": {
"enabled": true
},
"trafficLogs": {
"enabled": true
}
},
"mcpTools": {},
"operations": {}
}
}
}
'import requests
url = "https://{tenant}/api/mcps"
payload = {
"openapi": "3.0.3",
"info": {
"title": "MCP Proxy Sample",
"version": "1.0.0"
},
"paths": {},
"components": {},
"servers": [{ "url": "/mcp-sample/" }],
"x-tyk-api-gateway": {
"info": {
"name": "mcp-sample",
"state": { "active": True }
},
"server": {
"listenPath": {
"strip": True,
"value": "/mcp-sample/"
},
"authentication": {
"enabled": True,
"securitySchemes": { "authToken": { "enabled": True } }
}
},
"upstream": { "url": "http://localhost:7878/mcp" },
"middleware": {
"global": {
"contextVariables": { "enabled": True },
"trafficLogs": { "enabled": True }
},
"mcpTools": {},
"operations": {}
}
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
openapi: '3.0.3',
info: {title: 'MCP Proxy Sample', version: '1.0.0'},
paths: {},
components: {},
servers: [{url: '/mcp-sample/'}],
'x-tyk-api-gateway': {
info: {name: 'mcp-sample', state: {active: true}},
server: {
listenPath: {strip: true, value: '/mcp-sample/'},
authentication: {enabled: true, securitySchemes: {authToken: {enabled: true}}}
},
upstream: {url: 'http://localhost:7878/mcp'},
middleware: {
global: {contextVariables: {enabled: true}, trafficLogs: {enabled: true}},
mcpTools: {},
operations: {}
}
}
})
};
fetch('https://{tenant}/api/mcps', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenant}/api/mcps",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'openapi' => '3.0.3',
'info' => [
'title' => 'MCP Proxy Sample',
'version' => '1.0.0'
],
'paths' => [
],
'components' => [
],
'servers' => [
[
'url' => '/mcp-sample/'
]
],
'x-tyk-api-gateway' => [
'info' => [
'name' => 'mcp-sample',
'state' => [
'active' => true
]
],
'server' => [
'listenPath' => [
'strip' => true,
'value' => '/mcp-sample/'
],
'authentication' => [
'enabled' => true,
'securitySchemes' => [
'authToken' => [
'enabled' => true
]
]
]
],
'upstream' => [
'url' => 'http://localhost:7878/mcp'
],
'middleware' => [
'global' => [
'contextVariables' => [
'enabled' => true
],
'trafficLogs' => [
'enabled' => true
]
],
'mcpTools' => [
],
'operations' => [
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{tenant}/api/mcps"
payload := strings.NewReader("{\n \"openapi\": \"3.0.3\",\n \"info\": {\n \"title\": \"MCP Proxy Sample\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {},\n \"components\": {},\n \"servers\": [\n {\n \"url\": \"/mcp-sample/\"\n }\n ],\n \"x-tyk-api-gateway\": {\n \"info\": {\n \"name\": \"mcp-sample\",\n \"state\": {\n \"active\": true\n }\n },\n \"server\": {\n \"listenPath\": {\n \"strip\": true,\n \"value\": \"/mcp-sample/\"\n },\n \"authentication\": {\n \"enabled\": true,\n \"securitySchemes\": {\n \"authToken\": {\n \"enabled\": true\n }\n }\n }\n },\n \"upstream\": {\n \"url\": \"http://localhost:7878/mcp\"\n },\n \"middleware\": {\n \"global\": {\n \"contextVariables\": {\n \"enabled\": true\n },\n \"trafficLogs\": {\n \"enabled\": true\n }\n },\n \"mcpTools\": {},\n \"operations\": {}\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{tenant}/api/mcps")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"openapi\": \"3.0.3\",\n \"info\": {\n \"title\": \"MCP Proxy Sample\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {},\n \"components\": {},\n \"servers\": [\n {\n \"url\": \"/mcp-sample/\"\n }\n ],\n \"x-tyk-api-gateway\": {\n \"info\": {\n \"name\": \"mcp-sample\",\n \"state\": {\n \"active\": true\n }\n },\n \"server\": {\n \"listenPath\": {\n \"strip\": true,\n \"value\": \"/mcp-sample/\"\n },\n \"authentication\": {\n \"enabled\": true,\n \"securitySchemes\": {\n \"authToken\": {\n \"enabled\": true\n }\n }\n }\n },\n \"upstream\": {\n \"url\": \"http://localhost:7878/mcp\"\n },\n \"middleware\": {\n \"global\": {\n \"contextVariables\": {\n \"enabled\": true\n },\n \"trafficLogs\": {\n \"enabled\": true\n }\n },\n \"mcpTools\": {},\n \"operations\": {}\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/api/mcps")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"openapi\": \"3.0.3\",\n \"info\": {\n \"title\": \"MCP Proxy Sample\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {},\n \"components\": {},\n \"servers\": [\n {\n \"url\": \"/mcp-sample/\"\n }\n ],\n \"x-tyk-api-gateway\": {\n \"info\": {\n \"name\": \"mcp-sample\",\n \"state\": {\n \"active\": true\n }\n },\n \"server\": {\n \"listenPath\": {\n \"strip\": true,\n \"value\": \"/mcp-sample/\"\n },\n \"authentication\": {\n \"enabled\": true,\n \"securitySchemes\": {\n \"authToken\": {\n \"enabled\": true\n }\n }\n }\n },\n \"upstream\": {\n \"url\": \"http://localhost:7878/mcp\"\n },\n \"middleware\": {\n \"global\": {\n \"contextVariables\": {\n \"enabled\": true\n },\n \"trafficLogs\": {\n \"enabled\": true\n }\n },\n \"mcpTools\": {},\n \"operations\": {}\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"Status": "OK",
"Message": "MCP Proxy definition created",
"ID": "e30bee13ad4248c3b529a4c58bb7be4e"
}{
"Status": "Error",
"Message": "the payload should contain x-tyk-api-gateway"
}{
"ID": "<string>",
"Message": "<string>",
"Meta": "<unknown>",
"Status": "<string>"
}MCP Proxies
Create an MCP Proxy definition.
Create an MCP Proxy definition. The request body is a Tyk OAS document that
must contain x-tyk-api-gateway with MCP configuration. The payload is
validated against the MCP JSON schema and rejected if it uses any restricted
middleware (transformRequestMethod, transformResponseBody, urlRewrite,
internal, cache, validateRequest, mockResponse).
POST
/
api
/
mcps
Create an MCP Proxy definition.
curl --request POST \
--url https://{tenant}/api/mcps \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"openapi": "3.0.3",
"info": {
"title": "MCP Proxy Sample",
"version": "1.0.0"
},
"paths": {},
"components": {},
"servers": [
{
"url": "/mcp-sample/"
}
],
"x-tyk-api-gateway": {
"info": {
"name": "mcp-sample",
"state": {
"active": true
}
},
"server": {
"listenPath": {
"strip": true,
"value": "/mcp-sample/"
},
"authentication": {
"enabled": true,
"securitySchemes": {
"authToken": {
"enabled": true
}
}
}
},
"upstream": {
"url": "http://localhost:7878/mcp"
},
"middleware": {
"global": {
"contextVariables": {
"enabled": true
},
"trafficLogs": {
"enabled": true
}
},
"mcpTools": {},
"operations": {}
}
}
}
'import requests
url = "https://{tenant}/api/mcps"
payload = {
"openapi": "3.0.3",
"info": {
"title": "MCP Proxy Sample",
"version": "1.0.0"
},
"paths": {},
"components": {},
"servers": [{ "url": "/mcp-sample/" }],
"x-tyk-api-gateway": {
"info": {
"name": "mcp-sample",
"state": { "active": True }
},
"server": {
"listenPath": {
"strip": True,
"value": "/mcp-sample/"
},
"authentication": {
"enabled": True,
"securitySchemes": { "authToken": { "enabled": True } }
}
},
"upstream": { "url": "http://localhost:7878/mcp" },
"middleware": {
"global": {
"contextVariables": { "enabled": True },
"trafficLogs": { "enabled": True }
},
"mcpTools": {},
"operations": {}
}
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
openapi: '3.0.3',
info: {title: 'MCP Proxy Sample', version: '1.0.0'},
paths: {},
components: {},
servers: [{url: '/mcp-sample/'}],
'x-tyk-api-gateway': {
info: {name: 'mcp-sample', state: {active: true}},
server: {
listenPath: {strip: true, value: '/mcp-sample/'},
authentication: {enabled: true, securitySchemes: {authToken: {enabled: true}}}
},
upstream: {url: 'http://localhost:7878/mcp'},
middleware: {
global: {contextVariables: {enabled: true}, trafficLogs: {enabled: true}},
mcpTools: {},
operations: {}
}
}
})
};
fetch('https://{tenant}/api/mcps', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenant}/api/mcps",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'openapi' => '3.0.3',
'info' => [
'title' => 'MCP Proxy Sample',
'version' => '1.0.0'
],
'paths' => [
],
'components' => [
],
'servers' => [
[
'url' => '/mcp-sample/'
]
],
'x-tyk-api-gateway' => [
'info' => [
'name' => 'mcp-sample',
'state' => [
'active' => true
]
],
'server' => [
'listenPath' => [
'strip' => true,
'value' => '/mcp-sample/'
],
'authentication' => [
'enabled' => true,
'securitySchemes' => [
'authToken' => [
'enabled' => true
]
]
]
],
'upstream' => [
'url' => 'http://localhost:7878/mcp'
],
'middleware' => [
'global' => [
'contextVariables' => [
'enabled' => true
],
'trafficLogs' => [
'enabled' => true
]
],
'mcpTools' => [
],
'operations' => [
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{tenant}/api/mcps"
payload := strings.NewReader("{\n \"openapi\": \"3.0.3\",\n \"info\": {\n \"title\": \"MCP Proxy Sample\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {},\n \"components\": {},\n \"servers\": [\n {\n \"url\": \"/mcp-sample/\"\n }\n ],\n \"x-tyk-api-gateway\": {\n \"info\": {\n \"name\": \"mcp-sample\",\n \"state\": {\n \"active\": true\n }\n },\n \"server\": {\n \"listenPath\": {\n \"strip\": true,\n \"value\": \"/mcp-sample/\"\n },\n \"authentication\": {\n \"enabled\": true,\n \"securitySchemes\": {\n \"authToken\": {\n \"enabled\": true\n }\n }\n }\n },\n \"upstream\": {\n \"url\": \"http://localhost:7878/mcp\"\n },\n \"middleware\": {\n \"global\": {\n \"contextVariables\": {\n \"enabled\": true\n },\n \"trafficLogs\": {\n \"enabled\": true\n }\n },\n \"mcpTools\": {},\n \"operations\": {}\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{tenant}/api/mcps")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"openapi\": \"3.0.3\",\n \"info\": {\n \"title\": \"MCP Proxy Sample\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {},\n \"components\": {},\n \"servers\": [\n {\n \"url\": \"/mcp-sample/\"\n }\n ],\n \"x-tyk-api-gateway\": {\n \"info\": {\n \"name\": \"mcp-sample\",\n \"state\": {\n \"active\": true\n }\n },\n \"server\": {\n \"listenPath\": {\n \"strip\": true,\n \"value\": \"/mcp-sample/\"\n },\n \"authentication\": {\n \"enabled\": true,\n \"securitySchemes\": {\n \"authToken\": {\n \"enabled\": true\n }\n }\n }\n },\n \"upstream\": {\n \"url\": \"http://localhost:7878/mcp\"\n },\n \"middleware\": {\n \"global\": {\n \"contextVariables\": {\n \"enabled\": true\n },\n \"trafficLogs\": {\n \"enabled\": true\n }\n },\n \"mcpTools\": {},\n \"operations\": {}\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/api/mcps")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"openapi\": \"3.0.3\",\n \"info\": {\n \"title\": \"MCP Proxy Sample\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {},\n \"components\": {},\n \"servers\": [\n {\n \"url\": \"/mcp-sample/\"\n }\n ],\n \"x-tyk-api-gateway\": {\n \"info\": {\n \"name\": \"mcp-sample\",\n \"state\": {\n \"active\": true\n }\n },\n \"server\": {\n \"listenPath\": {\n \"strip\": true,\n \"value\": \"/mcp-sample/\"\n },\n \"authentication\": {\n \"enabled\": true,\n \"securitySchemes\": {\n \"authToken\": {\n \"enabled\": true\n }\n }\n }\n },\n \"upstream\": {\n \"url\": \"http://localhost:7878/mcp\"\n },\n \"middleware\": {\n \"global\": {\n \"contextVariables\": {\n \"enabled\": true\n },\n \"trafficLogs\": {\n \"enabled\": true\n }\n },\n \"mcpTools\": {},\n \"operations\": {}\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"Status": "OK",
"Message": "MCP Proxy definition created",
"ID": "e30bee13ad4248c3b529a4c58bb7be4e"
}{
"Status": "Error",
"Message": "the payload should contain x-tyk-api-gateway"
}{
"ID": "<string>",
"Message": "<string>",
"Meta": "<unknown>",
"Status": "<string>"
}Was this page helpful?
⌘I