|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// *mcp_gateway_config/mcp-gateway-register-virtual-mcp-servers.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="proc-verify-virt-mcp-server_{context}"] |
| 7 | += Verifying virtual MCP servers |
| 8 | + |
| 9 | +[role="_abstract"] |
| 10 | +After you create your virtual MCP servers, you can check that they are returning the tool lists that you want. |
| 11 | + |
| 12 | +.Prerequisites |
| 13 | + |
| 14 | +* You completed all of the installation and configuration steps for {mcpg}. |
| 15 | +* You registered your MCP servers. |
| 16 | +* You installed the {oc-first}. |
| 17 | +* You applied `MCPVirtualServer` custom resource (CRs) for your virtual servers. |
| 18 | +
|
| 19 | +.Procedure |
| 20 | + |
| 21 | +. List all of your virtual MCP servers by running the following command: |
| 22 | ++ |
| 23 | +[source,terminal] |
| 24 | +---- |
| 25 | +$ oc get mcpvirtualserver -A |
| 26 | +---- |
| 27 | ++ |
| 28 | +The expected output is a list of all of the virtual MCP servers that you created. |
| 29 | + |
| 30 | +. Performs a connectivity and handshake test of your virtual `dev_tools` MCP server by running the following `curl` command with the relevant URL and header: |
| 31 | ++ |
| 32 | +[source,terminal,subs="+quotes"] |
| 33 | +---- |
| 34 | +$ curl -s -D /tmp/mcp_headers -X POST _<http:example.com:port/mcp>_ \ |
| 35 | + -H "Content-Type: application/json" \ |
| 36 | + -d '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-11-25", "capabilities": {}, "clientInfo": {"name": "test-client", "version": "1.0.0"}}}' |
| 37 | +---- |
| 38 | ++ |
| 39 | +* Replace `_<http:example.com:port/mcp>_` with the target URL and MCP gateway endpoint. |
| 40 | ++ |
| 41 | +.Example output |
| 42 | +[source,json] |
| 43 | +---- |
| 44 | +{ |
| 45 | + "jsonrpc": "2.0", |
| 46 | + "id": 1, |
| 47 | + "result": { |
| 48 | + "protocolVersion": "2025-11-25", |
| 49 | + "capabilities": { |
| 50 | + "tools": {}, |
| 51 | + "prompts": {}, |
| 52 | + "resources": {} |
| 53 | + }, |
| 54 | + "serverInfo": { |
| 55 | + "name": "mcp-gateway-server", |
| 56 | + "version": "1.0.0" |
| 57 | + } |
| 58 | + } |
| 59 | +} |
| 60 | +---- |
| 61 | +
|
| 62 | +. Extract the MCP session ID from response headers by running the following command: |
| 63 | ++ |
| 64 | +[source,terminal] |
| 65 | +---- |
| 66 | +$ SESSION_ID=$(grep -i "mcp-session-id:" /tmp/mcp_headers | cut -d' ' -f2 | tr -d '\r') |
| 67 | +---- |
| 68 | ++ |
| 69 | +.Expected output |
| 70 | +[source,text] |
| 71 | +---- |
| 72 | +echo "MCP Session ID: $SESSION_ID" |
| 73 | +---- |
| 74 | + |
| 75 | +. Request the tools from the `dev_tools` virtual MCP server by running the following command: |
| 76 | ++ |
| 77 | +[source,terminal,subs="+quotes"] |
| 78 | +---- |
| 79 | +$ curl -X POST _<http:example.com:port/mcp>_ \ |
| 80 | + -H "Content-Type: application/json" \ |
| 81 | + -H "mcp-session-id: $SESSION_ID" \ |
| 82 | + -H "X-Mcp-Virtualserver: _<mcp_system>_/_<dev_tools>_" \ |
| 83 | + -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | jq '.result.tools[].name' |
| 84 | +---- |
| 85 | ++ |
| 86 | +* Replace `_<http:example.com:port/mcp>_` with the target URL and MCP gateway endpoint. |
| 87 | +* Replace `_<mcp_system>_` with the namespace of the MCP gateway. |
| 88 | +* Replace `_<dev_tools>_` with the tool headers that you want to request. |
| 89 | +* The expected response is a list of only the tools you specified in the `dev_tools` virtual MCP server specification. |
| 90 | +
|
| 91 | +. Request the tools from the `data_tools` virtual MCP server by running the following command: |
| 92 | ++ |
| 93 | +[source,terminal,subs="+quotes"] |
| 94 | +---- |
| 95 | +$ curl -X POST _<http:example.com:port>_/mcp \ |
| 96 | + -H "Content-Type: application/json" \ |
| 97 | + -H "mcp-session-id: $SESSION_ID" \ |
| 98 | + -H "X-Mcp-Virtualserver: _<mcp_system>_/_<data_tools>_" \ |
| 99 | + -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | jq '.result.tools[].name' |
| 100 | +---- |
| 101 | ++ |
| 102 | +* Replace `_<http:example.com:port/mcp>_` with the target URL and MCP gateway endpoint. |
| 103 | +* Replace `_<mcp_system>_` with the namespace of the MCP gateway. |
| 104 | +* Replace `_<data_tools>_` with the tool headers that you want to request. |
| 105 | +* The expected response is a list of only the tools you specified in the `data_tools` virtual MCP server specification. |
| 106 | +
|
| 107 | +. Request all available tools from your MCP servers by running the following command: |
| 108 | ++ |
| 109 | +[source,terminal,subs="+quotes"] |
| 110 | +---- |
| 111 | +$ curl -X POST _<http:example.com:port>_/mcp \ |
| 112 | + -H "mcp-session-id: $SESSION_ID" \ |
| 113 | + -H "Content-Type: application/json" \ |
| 114 | + -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | jq '.result.tools[].name' |
| 115 | +---- |
| 116 | ++ |
| 117 | +The expected response is a list of all tools from all registered MCP servers. |
0 commit comments