Skip to content

Commit 50ce10b

Browse files
Add mcpInputSchema to all service operations for MCP tool discovery
Populate inputSchema in /openapi-mcp.json so AI agents (Claude, Annie) can construct valid requests from natural language without documentation. - portfolioVariance: 7 properties (nAssets, weights, covarianceMatrix, covarianceMatrixFlat, normalizeWeights, nPeriodsPerYear, requestId) - monteCarlo: 9 properties with defaults (all optional — empty {} valid) - scenarioAnalysis: 4 properties with nested asset/scenario schema - doLogin: 2 required properties (email, credentials), mcpRequiresAuth=false - processBigDataSet: 2 required properties (datasetId, datasetSize) Schemas are declared as mcpInputSchema parameters in services.xml and parsed by OpenApiSpecGenerator.generateMcpCatalogJson() at runtime. Verified on local WildFly 32 and stg-rapi02 staging. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ea00f2b commit 50ce10b

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

modules/samples/userguide/src/userguide/springbootdemo-tomcat11/resources-axis2/bigdata_h2_resources/services.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@
7575
- Multiplexing for 10-50MB datasets
7676
- Standard for &lt;10MB datasets
7777
</description>
78+
<parameter name="mcpDescription">Process large JSON datasets with HTTP/2 streaming optimization. Automatically selects processing mode based on dataset size. Returns processing metrics including throughput, memory usage, and transport statistics.</parameter>
79+
<parameter name="mcpInputSchema">{
80+
"type": "object",
81+
"required": ["datasetId", "datasetSize"],
82+
"properties": {
83+
"datasetId": {"type": "string", "description": "Unique dataset identifier for tracking"},
84+
"datasetSize": {"type": "integer", "description": "Dataset size in bytes (determines processing mode: streaming for 50MB+, multiplexing for 10-50MB, standard for <10MB)"}
85+
}
86+
}</parameter>
7887
7988
<!-- HTTP/2 Operation Configuration -->
8089
<parameter name="enableHTTP2Streaming">true</parameter>

modules/samples/userguide/src/userguide/springbootdemo-tomcat11/resources-axis2/finbench_resources/services.xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@
2727
<parameter name="enableJSONOnly">true</parameter>
2828
<parameter name="disableSOAP">true</parameter>
2929
<operation name="portfolioVariance">
30+
<parameter name="mcpDescription">Calculate portfolio variance using O(n²) covariance matrix multiplication. Returns variance, volatility, annualized volatility. Supports up to 2000 assets with optional weight normalization and custom annualization periods (252 for equity, 365 for crypto, 12 for monthly).</parameter>
31+
<parameter name="mcpInputSchema">{
32+
"type": "object",
33+
"required": ["nAssets", "weights", "covarianceMatrix"],
34+
"properties": {
35+
"nAssets": {"type": "integer", "minimum": 2, "maximum": 2000, "description": "Number of assets in the portfolio"},
36+
"weights": {"type": "array", "items": {"type": "number"}, "description": "Portfolio weights. Must sum to 1.0 unless normalizeWeights=true"},
37+
"covarianceMatrix": {"type": "array", "items": {"type": "array", "items": {"type": "number"}}, "description": "n×n covariance matrix (2D array)"},
38+
"covarianceMatrixFlat": {"type": "array", "items": {"type": "number"}, "description": "Alternative: flattened n×n covariance matrix (row-major, length = nAssets²)"},
39+
"normalizeWeights": {"type": "boolean", "default": false, "description": "Rescale weights to sum to 1.0"},
40+
"nPeriodsPerYear": {"type": "integer", "default": 252, "description": "Trading periods for annualizing. 252=equity, 365=crypto, 12=monthly"},
41+
"requestId": {"type": "string", "description": "Optional request ID echoed in response for tracing"}
42+
}
43+
}</parameter>
3044
<messageReceivers>
3145
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
3246
class="org.apache.axis2.json.moshi.rpc.JsonRpcMessageReceiver"/>
@@ -35,6 +49,22 @@
3549
</messageReceivers>
3650
</operation>
3751
<operation name="monteCarlo">
52+
<parameter name="mcpDescription">Monte Carlo VaR simulation using Geometric Brownian Motion. Returns VaR at caller-specified percentiles, CVaR (expected shortfall), max drawdown, probability of profit, and throughput metrics. All parameters have sensible defaults — an empty request body is valid.</parameter>
53+
<parameter name="mcpInputSchema">{
54+
"type": "object",
55+
"required": [],
56+
"properties": {
57+
"nSimulations": {"type": "integer", "default": 10000, "maximum": 1000000, "description": "Number of simulation paths (max 1M)"},
58+
"nPeriods": {"type": "integer", "default": 252, "description": "Time steps per path (252 = 1 trading year)"},
59+
"initialValue": {"type": "number", "default": 1000000, "description": "Starting portfolio value in currency units"},
60+
"expectedReturn": {"type": "number", "default": 0.08, "description": "Annualized expected return (0.08 = 8%)"},
61+
"volatility": {"type": "number", "default": 0.20, "description": "Annualized volatility (0.20 = 20%)"},
62+
"randomSeed": {"type": "integer", "default": 0, "description": "RNG seed for reproducibility. 0 = non-deterministic"},
63+
"nPeriodsPerYear": {"type": "integer", "default": 252, "description": "Periods per year for GBM dt calculation"},
64+
"percentiles": {"type": "array", "items": {"type": "number"}, "default": [0.01, 0.05], "description": "VaR percentiles, e.g. [0.01, 0.05] for 99% and 95%"},
65+
"requestId": {"type": "string", "description": "Optional request ID echoed in response"}
66+
}
67+
}</parameter>
3868
<messageReceivers>
3969
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
4070
class="org.apache.axis2.json.moshi.rpc.JsonRpcMessageReceiver"/>
@@ -43,6 +73,32 @@
4373
</messageReceivers>
4474
</operation>
4575
<operation name="scenarioAnalysis">
76+
<parameter name="mcpDescription">Probability-weighted scenario analysis with hash table vs linear scan benchmarking. Computes expected return, upside potential, downside risk across user-defined price scenarios per asset.</parameter>
77+
<parameter name="mcpInputSchema">{
78+
"type": "object",
79+
"required": ["assets"],
80+
"properties": {
81+
"assets": {"type": "array", "description": "Portfolio assets with scenario prices and probabilities", "items": {
82+
"type": "object",
83+
"required": ["assetId", "currentPrice", "positionSize", "scenarios"],
84+
"properties": {
85+
"assetId": {"type": "integer", "description": "Unique asset identifier"},
86+
"currentPrice": {"type": "number", "description": "Current market price (must be > 0)"},
87+
"positionSize": {"type": "number", "description": "Number of shares/units held"},
88+
"scenarios": {"type": "array", "description": "Price scenarios with probabilities (must sum to 1.0)", "items": {
89+
"type": "object",
90+
"properties": {
91+
"price": {"type": "number", "description": "Scenario price"},
92+
"probability": {"type": "number", "description": "Scenario probability (0-1)"}
93+
}
94+
}}
95+
}
96+
}},
97+
"useHashLookup": {"type": "boolean", "default": true, "description": "Use HashMap for O(1) lookups vs ArrayList O(n) scan"},
98+
"probTolerance": {"type": "number", "default": 0.0001, "description": "Tolerance for probability sum validation"},
99+
"requestId": {"type": "string", "description": "Optional request ID echoed in response"}
100+
}
101+
}</parameter>
46102
<messageReceivers>
47103
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
48104
class="org.apache.axis2.json.moshi.rpc.JsonRpcMessageReceiver"/>

modules/samples/userguide/src/userguide/springbootdemo-tomcat11/resources-axis2/login_resources/services.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
<parameter name="ServiceObjectSupplier">org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier</parameter>
2424
<parameter name="SpringBeanName">loginService</parameter>
2525
<operation name="doLogin">
26+
<parameter name="mcpDescription">Authenticate and obtain a JWT Bearer token. The token is required in the Authorization header for all subsequent service calls.</parameter>
27+
<parameter name="mcpRequiresAuth">false</parameter>
28+
<parameter name="mcpInputSchema">{
29+
"type": "object",
30+
"required": ["email", "credentials"],
31+
"properties": {
32+
"email": {"type": "string", "description": "User email address"},
33+
"credentials": {"type": "string", "description": "User password"}
34+
}
35+
}</parameter>
2636
<messageReceivers>
2737
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
2838
class="org.apache.axis2.json.moshi.rpc.JsonRpcMessageReceiver" />

0 commit comments

Comments
 (0)