Compare commits

..

5 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
7eeb136233 Complete fix with screenshots and full testing
Co-authored-by: samanhappy <2755122+samanhappy@users.noreply.github.com>
2025-12-08 02:21:56 +00:00
copilot-swe-agent[bot]
db1d621a06 Fix export/import for OpenAPI server type and improve handling
Co-authored-by: samanhappy <2755122+samanhappy@users.noreply.github.com>
2025-12-08 02:18:20 +00:00
copilot-swe-agent[bot]
4affcb72d7 Initial investigation of export/import issue
Co-authored-by: samanhappy <2755122+samanhappy@users.noreply.github.com>
2025-12-08 02:12:39 +00:00
copilot-swe-agent[bot]
38e274d441 Initial plan 2025-12-08 02:04:27 +00:00
Alptekin Gülcan
ab7c210281 Optimizing API Operations: Simplified operationId Values and Large String Parameter Management (#488) 2025-12-07 13:11:35 +08:00
2 changed files with 68 additions and 4 deletions

View File

@@ -14,6 +14,13 @@ interface McpServerConfig {
type?: string;
url?: string;
headers?: Record<string, string>;
openapi?: {
url?: string;
schema?: Record<string, any>;
version?: string;
security?: any;
passthroughHeaders?: string[];
};
}
interface ImportJsonFormat {
@@ -61,6 +68,34 @@ HTTP example:
}
}
}
}
OpenAPI example (correct format):
{
"mcpServers": {
"openapi-server-example": {
"type": "openapi",
"openapi": {
"url": "http://localhost:3002/openapi.json"
},
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
OpenAPI example (legacy format, also supported):
{
"mcpServers": {
"openapi-server-legacy": {
"type": "openapi",
"url": "http://localhost:3002/openapi.json",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}`;
const parseAndValidateJson = (input: string): ImportJsonFormat | null => {
@@ -89,15 +124,34 @@ HTTP example:
// Normalize config to MCPHub format
const normalizedConfig: any = {};
// Handle different server types
if (config.type === 'sse' || config.type === 'streamable-http') {
// SSE and streamable-http servers use top-level url
normalizedConfig.type = config.type;
normalizedConfig.url = config.url;
if (config.headers) {
normalizedConfig.headers = config.headers;
}
} else if (config.type === 'openapi') {
// OpenAPI servers have special handling
normalizedConfig.type = 'openapi';
// Check if openapi configuration is already in correct format
if (config.openapi) {
normalizedConfig.openapi = config.openapi;
} else if (config.url) {
// Legacy format: convert top-level url to openapi.url
normalizedConfig.openapi = {
url: config.url,
};
}
if (config.headers) {
normalizedConfig.headers = config.headers;
}
} else {
// Default to stdio
normalizedConfig.type = 'stdio';
// Command-based servers (stdio or unspecified type)
normalizedConfig.type = config.type || 'stdio';
normalizedConfig.command = config.command;
normalizedConfig.args = config.args || [];
if (config.env) {
@@ -238,6 +292,16 @@ HTTP example:
<strong>{t('server.url')}:</strong> {server.config.url}
</div>
)}
{server.config.openapi?.url && (
<div>
<strong>OpenAPI URL:</strong> {server.config.openapi.url}
</div>
)}
{server.config.openapi?.schema && (
<div>
<strong>OpenAPI Schema:</strong> (Inline schema provided)
</div>
)}
{server.config.env && Object.keys(server.config.env).length > 0 && (
<div>
<strong>{t('server.envVars')}:</strong>{' '}

View File

@@ -42,7 +42,7 @@ function convertToolSchemaToOpenAPI(tool: Tool): {
(prop: any) =>
prop.type === 'object' ||
prop.type === 'array' ||
(prop.type === 'string' && prop.enum && prop.enum.length > 10),
prop.type === 'string',
);
if (!hasComplexTypes && Object.keys(properties).length <= 10) {
@@ -93,7 +93,7 @@ function generateOperationFromTool(tool: Tool, serverName: string): OpenAPIV3.Op
const operation: OpenAPIV3.OperationObject = {
summary: tool.description || `Execute ${tool.name} tool`,
description: tool.description || `Execute the ${tool.name} tool from ${serverName} server`,
operationId: `${serverName}_${tool.name}`,
operationId: `${tool.name}`,
tags: [serverName],
...(parameters && parameters.length > 0 && { parameters }),
...(requestBody && { requestBody }),