Skip to content

Commit ab3fb03

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add mcp step subtype to synthetics multi-step api tests (#3861)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 875d113 commit ab3fb03

18 files changed

Lines changed: 1443 additions & 15 deletions

.generator/schemas/v1/openapi.yaml

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16342,6 +16342,7 @@ components:
1634216342
- udp
1634316343
- icmp
1634416344
- websocket
16345+
- mcp
1634516346
example: http
1634616347
type: string
1634716348
x-enum-varnames:
@@ -16353,6 +16354,7 @@ components:
1635316354
- UDP
1635416355
- ICMP
1635516356
- WEBSOCKET
16357+
- MCP
1635616358
SyntheticsAPITestType:
1635716359
default: "api"
1635816360
description: Type of the Synthetic test, `api`.
@@ -16475,6 +16477,8 @@ components:
1647516477
- $ref: "#/components/schemas/SyntheticsAssertionJSONSchemaTarget"
1647616478
- $ref: "#/components/schemas/SyntheticsAssertionXPathTarget"
1647716479
- $ref: "#/components/schemas/SyntheticsAssertionJavascript"
16480+
- $ref: "#/components/schemas/SyntheticsAssertionMCPServerCapabilitiesTarget"
16481+
- $ref: "#/components/schemas/SyntheticsAssertionMCPRespectsSpecification"
1647816482
SyntheticsAssertionBodyHashOperator:
1647916483
description: Assertion operator to apply.
1648016484
enum:
@@ -16610,6 +16614,49 @@ components:
1661016614
type: string
1661116615
x-enum-varnames:
1661216616
- JAVASCRIPT
16617+
SyntheticsAssertionMCPRespectsSpecification:
16618+
description: An assertion that verifies the MCP server response respects the MCP specification.
16619+
properties:
16620+
type:
16621+
$ref: "#/components/schemas/SyntheticsAssertionMCPRespectsSpecificationType"
16622+
required:
16623+
- type
16624+
type: object
16625+
SyntheticsAssertionMCPRespectsSpecificationType:
16626+
description: Type of the assertion.
16627+
enum:
16628+
- mcpRespectsSpecification
16629+
example: mcpRespectsSpecification
16630+
type: string
16631+
x-enum-varnames:
16632+
- MCP_RESPECTS_SPECIFICATION
16633+
SyntheticsAssertionMCPServerCapabilitiesTarget:
16634+
description: An assertion that checks that an MCP server advertises the expected capabilities.
16635+
properties:
16636+
operator:
16637+
$ref: "#/components/schemas/SyntheticsAssertionOperator"
16638+
target:
16639+
description: List of MCP server capabilities to assert against.
16640+
example:
16641+
- completions
16642+
items:
16643+
$ref: "#/components/schemas/SyntheticsMCPServerCapability"
16644+
type: array
16645+
type:
16646+
$ref: "#/components/schemas/SyntheticsAssertionMCPServerCapabilitiesType"
16647+
required:
16648+
- type
16649+
- operator
16650+
- target
16651+
type: object
16652+
SyntheticsAssertionMCPServerCapabilitiesType:
16653+
description: Type of the assertion.
16654+
enum:
16655+
- mcpServerCapabilities
16656+
example: mcpServerCapabilities
16657+
type: string
16658+
x-enum-varnames:
16659+
- MCP_SERVER_CAPABILITIES
1661316660
SyntheticsAssertionOperator:
1661416661
description: Assertion operator to apply.
1661516662
enum:
@@ -16712,6 +16759,8 @@ components:
1671216759
- connection
1671316760
- multiNetworkHop
1671416761
- jitter
16762+
- mcpToolNameLength
16763+
- mcpToolCount
1671516764
example: statusCode
1671616765
type: string
1671716766
x-enum-varnames:
@@ -16736,6 +16785,8 @@ components:
1673616785
- CONNECTION
1673716786
- MULTI_NETWORK_HOP
1673816787
- JITTER
16788+
- MCP_TOOL_NAME_LENGTH
16789+
- MCP_TOOL_COUNT
1673916790
SyntheticsAssertionXPathOperator:
1674016791
description: Assertion operator to apply.
1674116792
enum:
@@ -18044,6 +18095,31 @@ components:
1804418095
$ref: "#/components/schemas/SyntheticsLocation"
1804518096
type: array
1804618097
type: object
18098+
SyntheticsMCPProtocolVersion:
18099+
description: The MCP protocol version used by the step. See https://modelcontextprotocol.io/specification.
18100+
enum:
18101+
- "2025-06-18"
18102+
example: "2025-06-18"
18103+
type: string
18104+
x-enum-varnames:
18105+
- VERSION_2025_06_18
18106+
SyntheticsMCPServerCapability:
18107+
description: A capability advertised by an MCP server.
18108+
enum:
18109+
- completions
18110+
- experimental
18111+
- logging
18112+
- prompts
18113+
- resources
18114+
- tools
18115+
type: string
18116+
x-enum-varnames:
18117+
- COMPLETIONS
18118+
- EXPERIMENTAL
18119+
- LOGGING
18120+
- PROMPTS
18121+
- RESOURCES
18122+
- TOOLS
1804718123
SyntheticsMobileStep:
1804818124
description: The steps used in a Synthetic mobile test.
1804918125
properties:
@@ -18933,15 +19009,24 @@ components:
1893319009
- UPLOAD_FILES
1893419010
- WAIT
1893519011
SyntheticsTestCallType:
18936-
description: The type of gRPC call to perform.
19012+
description: |-
19013+
The type of call to perform. Used by gRPC steps (`healthcheck`, `unary`)
19014+
and MCP steps (`init`, `tool_list`, `tool_call`). Valid values depend on
19015+
the parent step's `subtype`.
1893719016
enum:
1893819017
- healthcheck
1893919018
- unary
19019+
- init
19020+
- tool_list
19021+
- tool_call
1894019022
example: unary
1894119023
type: string
1894219024
x-enum-varnames:
1894319025
- HEALTHCHECK
1894419026
- UNARY
19027+
- INIT
19028+
- TOOL_LIST
19029+
- TOOL_CALL
1894519030
SyntheticsTestCiOptions:
1894619031
description: CI/CD options for a Synthetic test.
1894719032
properties:
@@ -19442,6 +19527,8 @@ components:
1944219527
isMessageBase64Encoded:
1944319528
description: Whether the message is base64 encoded.
1944419529
type: boolean
19530+
mcpProtocolVersion:
19531+
$ref: "#/components/schemas/SyntheticsMCPProtocolVersion"
1944519532
message:
1944619533
description: Message to send for UDP or WebSocket tests.
1944719534
type: string
@@ -19486,6 +19573,14 @@ components:
1948619573
description: Timeout in seconds for the test.
1948719574
format: double
1948819575
type: number
19576+
toolArgs:
19577+
additionalProperties: {}
19578+
description: Arguments to pass to the MCP tool. Free-form object whose shape depends on the tool. Used when `callType` is `tool_call`.
19579+
type: object
19580+
toolName:
19581+
description: The name of the MCP tool to call. Required when `callType` is `tool_call`.
19582+
example: search
19583+
type: string
1948919584
url:
1949019585
description: URL to perform the test with.
1949119586
example: "https://example.com"
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
// Create an API test with MCP steps returns "OK - Returns the created test details." response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v1.api.SyntheticsApi;
6+
import com.datadog.api.client.v1.model.SyntheticsAPIStep;
7+
import com.datadog.api.client.v1.model.SyntheticsAPITest;
8+
import com.datadog.api.client.v1.model.SyntheticsAPITestConfig;
9+
import com.datadog.api.client.v1.model.SyntheticsAPITestStep;
10+
import com.datadog.api.client.v1.model.SyntheticsAPITestStepSubtype;
11+
import com.datadog.api.client.v1.model.SyntheticsAPITestType;
12+
import com.datadog.api.client.v1.model.SyntheticsAssertion;
13+
import com.datadog.api.client.v1.model.SyntheticsAssertionMCPRespectsSpecification;
14+
import com.datadog.api.client.v1.model.SyntheticsAssertionMCPRespectsSpecificationType;
15+
import com.datadog.api.client.v1.model.SyntheticsAssertionMCPServerCapabilitiesTarget;
16+
import com.datadog.api.client.v1.model.SyntheticsAssertionMCPServerCapabilitiesType;
17+
import com.datadog.api.client.v1.model.SyntheticsAssertionOperator;
18+
import com.datadog.api.client.v1.model.SyntheticsAssertionTarget;
19+
import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue;
20+
import com.datadog.api.client.v1.model.SyntheticsAssertionType;
21+
import com.datadog.api.client.v1.model.SyntheticsMCPProtocolVersion;
22+
import com.datadog.api.client.v1.model.SyntheticsMCPServerCapability;
23+
import com.datadog.api.client.v1.model.SyntheticsTestCallType;
24+
import com.datadog.api.client.v1.model.SyntheticsTestDetailsSubType;
25+
import com.datadog.api.client.v1.model.SyntheticsTestOptions;
26+
import com.datadog.api.client.v1.model.SyntheticsTestOptionsRetry;
27+
import com.datadog.api.client.v1.model.SyntheticsTestRequest;
28+
import java.util.Arrays;
29+
import java.util.Collections;
30+
import java.util.Map;
31+
32+
public class Example {
33+
public static void main(String[] args) {
34+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
35+
SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
36+
37+
SyntheticsAPITest body =
38+
new SyntheticsAPITest()
39+
.config(
40+
new SyntheticsAPITestConfig()
41+
.steps(
42+
Arrays.asList(
43+
new SyntheticsAPIStep(
44+
new SyntheticsAPITestStep()
45+
.name("Initialize MCP session")
46+
.subtype(SyntheticsAPITestStepSubtype.MCP)
47+
.allowFailure(false)
48+
.isCritical(true)
49+
.retry(
50+
new SyntheticsTestOptionsRetry().count(0L).interval(300.0))
51+
.assertions(
52+
Arrays.asList(
53+
new SyntheticsAssertion(
54+
new SyntheticsAssertionTarget()
55+
.operator(SyntheticsAssertionOperator.IS)
56+
.type(SyntheticsAssertionType.STATUS_CODE)
57+
.target(
58+
new SyntheticsAssertionTargetValue(200.0))),
59+
new SyntheticsAssertion(
60+
new SyntheticsAssertionMCPRespectsSpecification()
61+
.type(
62+
SyntheticsAssertionMCPRespectsSpecificationType
63+
.MCP_RESPECTS_SPECIFICATION)),
64+
new SyntheticsAssertion(
65+
new SyntheticsAssertionMCPServerCapabilitiesTarget()
66+
.operator(SyntheticsAssertionOperator.CONTAINS)
67+
.type(
68+
SyntheticsAssertionMCPServerCapabilitiesType
69+
.MCP_SERVER_CAPABILITIES)
70+
.target(
71+
Collections.singletonList(
72+
SyntheticsMCPServerCapability.TOOLS)))))
73+
.request(
74+
new SyntheticsTestRequest()
75+
.url("https://example.org/mcp")
76+
.callType(SyntheticsTestCallType.INIT)
77+
.mcpProtocolVersion(
78+
SyntheticsMCPProtocolVersion.VERSION_2025_06_18)
79+
.headers(
80+
Map.ofEntries(
81+
Map.entry("DD-API-KEY", "<YOUR-API-KEY>"),
82+
Map.entry(
83+
"DD-APPLICATION-KEY", "<YOUR-APP-KEY>"))))),
84+
new SyntheticsAPIStep(
85+
new SyntheticsAPITestStep()
86+
.name("List MCP tools")
87+
.subtype(SyntheticsAPITestStepSubtype.MCP)
88+
.allowFailure(false)
89+
.isCritical(true)
90+
.retry(
91+
new SyntheticsTestOptionsRetry().count(0L).interval(300.0))
92+
.assertions(
93+
Arrays.asList(
94+
new SyntheticsAssertion(
95+
new SyntheticsAssertionTarget()
96+
.operator(SyntheticsAssertionOperator.IS)
97+
.type(SyntheticsAssertionType.STATUS_CODE)
98+
.target(
99+
new SyntheticsAssertionTargetValue(200.0))),
100+
new SyntheticsAssertion(
101+
new SyntheticsAssertionTarget()
102+
.operator(SyntheticsAssertionOperator.MORE_THAN)
103+
.type(SyntheticsAssertionType.MCP_TOOL_COUNT)
104+
.target(
105+
new SyntheticsAssertionTargetValue(0.0))),
106+
new SyntheticsAssertion(
107+
new SyntheticsAssertionTarget()
108+
.operator(SyntheticsAssertionOperator.LESS_THAN)
109+
.type(
110+
SyntheticsAssertionType
111+
.MCP_TOOL_NAME_LENGTH)
112+
.target(
113+
new SyntheticsAssertionTargetValue(64.0))),
114+
new SyntheticsAssertion(
115+
new SyntheticsAssertionMCPRespectsSpecification()
116+
.type(
117+
SyntheticsAssertionMCPRespectsSpecificationType
118+
.MCP_RESPECTS_SPECIFICATION))))
119+
.request(
120+
new SyntheticsTestRequest()
121+
.url("https://example.org/mcp")
122+
.callType(SyntheticsTestCallType.TOOL_LIST)
123+
.mcpProtocolVersion(
124+
SyntheticsMCPProtocolVersion.VERSION_2025_06_18)
125+
.headers(
126+
Map.ofEntries(
127+
Map.entry("DD-API-KEY", "<YOUR-API-KEY>"),
128+
Map.entry(
129+
"DD-APPLICATION-KEY", "<YOUR-APP-KEY>"))))),
130+
new SyntheticsAPIStep(
131+
new SyntheticsAPITestStep()
132+
.name("Call MCP search tool")
133+
.subtype(SyntheticsAPITestStepSubtype.MCP)
134+
.allowFailure(false)
135+
.isCritical(true)
136+
.retry(
137+
new SyntheticsTestOptionsRetry().count(0L).interval(300.0))
138+
.assertions(
139+
Arrays.asList(
140+
new SyntheticsAssertion(
141+
new SyntheticsAssertionTarget()
142+
.operator(SyntheticsAssertionOperator.IS)
143+
.type(SyntheticsAssertionType.STATUS_CODE)
144+
.target(
145+
new SyntheticsAssertionTargetValue(200.0))),
146+
new SyntheticsAssertion(
147+
new SyntheticsAssertionTarget()
148+
.operator(SyntheticsAssertionOperator.LESS_THAN)
149+
.type(SyntheticsAssertionType.RESPONSE_TIME)
150+
.target(
151+
new SyntheticsAssertionTargetValue(
152+
5000.0))),
153+
new SyntheticsAssertion(
154+
new SyntheticsAssertionMCPRespectsSpecification()
155+
.type(
156+
SyntheticsAssertionMCPRespectsSpecificationType
157+
.MCP_RESPECTS_SPECIFICATION))))
158+
.request(
159+
new SyntheticsTestRequest()
160+
.url("https://example.org/mcp")
161+
.callType(SyntheticsTestCallType.TOOL_CALL)
162+
.mcpProtocolVersion(
163+
SyntheticsMCPProtocolVersion.VERSION_2025_06_18)
164+
.toolName("search")
165+
.toolArgs(
166+
Map.ofEntries(
167+
Map.entry("limit", "5"),
168+
Map.entry("query", "datadog synthetics")))
169+
.headers(
170+
Map.ofEntries(
171+
Map.entry("DD-API-KEY", "<YOUR-API-KEY>"),
172+
Map.entry(
173+
"DD-APPLICATION-KEY",
174+
"<YOUR-APP-KEY>"))))))))
175+
.locations(Collections.singletonList("aws:us-east-2"))
176+
.message("BDD test payload: synthetics_api_test_mcp_payload.json")
177+
.name("Example-Synthetic")
178+
.options(
179+
new SyntheticsTestOptions()
180+
.minFailureDuration(10L)
181+
.minLocationFailed(1L)
182+
.monitorName("Example-Synthetic")
183+
.monitorPriority(5)
184+
.retry(new SyntheticsTestOptionsRetry().count(3L).interval(1000.0))
185+
.tickEvery(900L))
186+
.subtype(SyntheticsTestDetailsSubType.MULTI)
187+
.tags(Collections.singletonList("testing:api"))
188+
.type(SyntheticsAPITestType.API);
189+
190+
try {
191+
SyntheticsAPITest result = apiInstance.createSyntheticsAPITest(body);
192+
System.out.println(result);
193+
} catch (ApiException e) {
194+
System.err.println("Exception when calling SyntheticsApi#createSyntheticsAPITest");
195+
System.err.println("Status code: " + e.getCode());
196+
System.err.println("Reason: " + e.getResponseBody());
197+
System.err.println("Response headers: " + e.getResponseHeaders());
198+
e.printStackTrace();
199+
}
200+
}
201+
}

0 commit comments

Comments
 (0)