Skip to content

Commit 3197b8f

Browse files
committed
fixing mcp bicep
1 parent 64acd64 commit 3197b8f

2 files changed

Lines changed: 1376 additions & 55 deletions

File tree

tests/integration/all-resource-types/source-apim.bicep

Lines changed: 40 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -902,35 +902,67 @@ resource apiRevisionedRev2 'Microsoft.ApiManagement/service/apis@2025-09-01-prev
902902
}
903903

904904
// 8. MCP API created from an existing REST API in the instance
905+
// mcpTools live directly on the API resource (not a child mcpServers resource)
906+
// any() used because mcpTools is valid at runtime but absent from Bicep type definitions (BCP037)
905907
resource apiMcpFromApi 'Microsoft.ApiManagement/service/apis@2025-09-01-preview' = {
906908
parent: apim
907909
name: 'src-mcp-from-api'
908-
properties: {
910+
dependsOn: [apiRestOpenapi]
911+
properties: any({
909912
displayName: 'KS MCP from Existing API'
910913
description: 'MCP server created by exposing an existing REST API in the instance as MCP tools'
911914
path: 'ks/mcp-from-api'
912915
protocols: ['https']
913-
serviceUrl: 'https://src-mcp-from-api-backend.example.com/api'
914916
subscriptionRequired: false
915917
type: 'mcp'
916-
apiType: 'mcp'
918+
mcpTools: [
919+
{
920+
name: 'healthCheck'
921+
description: 'Health check endpoint'
922+
operationId: resourceId('Microsoft.ApiManagement/service/apis/operations', apimName, 'src-rest-openapi', 'healthCheck')
923+
}
924+
{
925+
name: 'listItems'
926+
description: 'List all items'
927+
operationId: resourceId('Microsoft.ApiManagement/service/apis/operations', apimName, 'src-rest-openapi', 'listItems')
928+
}
929+
]
930+
})
931+
}
932+
933+
// Backend for external MCP server (backendId pattern requires a backend resource)
934+
resource backendMcpExternal 'Microsoft.ApiManagement/service/backends@2025-09-01-preview' = {
935+
parent: apim
936+
name: 'src-backend-mcp-external'
937+
properties: {
938+
description: 'External MCP server backend (GitHub Copilot)'
939+
url: 'https://api.githubcopilot.com/mcp'
940+
protocol: 'http'
917941
}
918942
}
919943

920944
// 9. MCP API created from an existing (external) public MCP server
945+
// External MCP uses backendId + mcpProperties (path must be empty)
946+
// any() used because backendId and mcpProperties.endpoints are valid at runtime but absent from Bicep type definitions (BCP037/BCP036)
921947
resource apiMcpFromExternal 'Microsoft.ApiManagement/service/apis@2025-09-01-preview' = {
922948
parent: apim
923949
name: 'src-mcp-from-external'
924-
properties: {
950+
properties: any({
925951
displayName: 'KS MCP from External Server'
926952
description: 'MCP server repackaging a public external MCP server via APIM'
927-
path: 'ks/mcp-external'
953+
path: ''
928954
protocols: ['https']
929-
serviceUrl: 'https://api.githubcopilot.com/mcp'
930955
subscriptionRequired: false
931956
type: 'mcp'
932-
apiType: 'mcp'
933-
}
957+
backendId: backendMcpExternal.name
958+
mcpProperties: {
959+
endpoints: {
960+
mcp: {
961+
uriTemplate: '/mcp'
962+
}
963+
}
964+
}
965+
})
934966
}
935967

936968
// ---------------------------------------------------------------------------
@@ -1054,53 +1086,6 @@ resource apiRestOpPolicy 'Microsoft.ApiManagement/service/apis/operations/polici
10541086
}
10551087
}
10561088

1057-
// --- Explicit API Operation (on MCP from-API API for full coverage of ApiOperation resource type) ---
1058-
resource apiMcpOperation 'Microsoft.ApiManagement/service/apis/operations@2025-09-01-preview' = {
1059-
parent: apiMcpFromApi
1060-
name: 'src-mcp-invoke'
1061-
properties: {
1062-
displayName: 'Invoke MCP Tool'
1063-
method: 'POST'
1064-
urlTemplate: '/tools/invoke'
1065-
description: 'Explicit operation for BVT coverage of ApiOperation resource type'
1066-
responses: [
1067-
{
1068-
statusCode: 200
1069-
description: 'Tool invocation result'
1070-
}
1071-
]
1072-
}
1073-
}
1074-
1075-
// --- MCP Server (from existing API) ---
1076-
resource mcpServerFromApi 'Microsoft.ApiManagement/service/apis/mcpServers@2025-09-01-preview' = {
1077-
parent: apiMcpFromApi
1078-
name: 'default'
1079-
properties: {
1080-
mcpTools: [
1081-
{
1082-
name: 'httpGet'
1083-
description: 'Perform a GET request via the underlying REST API backend'
1084-
}
1085-
{
1086-
name: 'httpPost'
1087-
description: 'Perform a POST request via the underlying REST API backend'
1088-
}
1089-
]
1090-
}
1091-
}
1092-
1093-
// --- MCP Server (from external MCP server) ---
1094-
resource mcpServerFromExternal 'Microsoft.ApiManagement/service/apis/mcpServers@2025-09-01-preview' = {
1095-
parent: apiMcpFromExternal
1096-
name: 'default'
1097-
properties: {
1098-
mcpProperties: {
1099-
serverUrl: 'https://api.githubcopilot.com/mcp'
1100-
}
1101-
}
1102-
}
1103-
11041089
// --- Explicit API Schema (on REST API for full coverage) ---
11051090
resource apiRestSchema 'Microsoft.ApiManagement/service/apis/schemas@2025-09-01-preview' = {
11061091
parent: apiRestOpenapi

0 commit comments

Comments
 (0)