include the in=query parameters in the inputSchema
When a parameter has `in` = `query`, it means the value is passed as an HTTP parameter in the
URL of the query.
e.g:
```
"parameters": [
{
"description": "A search term.",
"in": "query",
"name": "search",
"required": false,
"type": "string"
},
(...)
```
This commit is contained in:
parent
f29c277860
commit
960a3b38aa
@ -7,6 +7,16 @@ import { generateOperationId } from '../utils/code-gen.js';
|
||||
import { McpToolDefinition } from '../types/index.js';
|
||||
import { shouldIncludeOperationForMcp } from '../utils/helpers.js';
|
||||
|
||||
export interface ParameterObjectWithType extends OpenAPIV3.ParameterObject {
|
||||
name: string;
|
||||
description?: string;
|
||||
in: string;
|
||||
type?: JSONSchema7TypeName;
|
||||
required?: boolean;
|
||||
schema?: OpenAPIV3.SchemaObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extracts tool definitions from an OpenAPI document
|
||||
*
|
||||
@ -124,8 +134,8 @@ export function generateInputSchemaAndDetails(operation: OpenAPIV3.OperationObje
|
||||
const required: string[] = [];
|
||||
|
||||
// Process parameters
|
||||
const allParameters: OpenAPIV3.ParameterObject[] = Array.isArray(operation.parameters)
|
||||
? operation.parameters.map((p) => p as OpenAPIV3.ParameterObject)
|
||||
const allParameters: ParameterObjectWithType[] = Array.isArray(operation.parameters)
|
||||
? operation.parameters.map((p) => p as ParameterObjectWithType)
|
||||
: [];
|
||||
|
||||
allParameters.forEach((param) => {
|
||||
@ -174,6 +184,16 @@ export function generateInputSchemaAndDetails(operation: OpenAPIV3.OperationObje
|
||||
}
|
||||
}
|
||||
|
||||
allParameters.forEach((item) => {
|
||||
if (properties[item.name]) return;
|
||||
properties[item.name] = {
|
||||
description: item.description,
|
||||
type: item.type ?? item.schema?.type,
|
||||
};
|
||||
|
||||
if (item.required) required.push(item.name);
|
||||
});
|
||||
|
||||
// Combine everything into a JSON Schema
|
||||
const inputSchema: JSONSchema7 = {
|
||||
type: 'object',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user