mirror of
https://github.com/samanhappy/mcphub.git
synced 2025-12-24 02:39:19 -05:00
Compare commits
4 Commits
v0.11.6
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eeb136233 | ||
|
|
db1d621a06 | ||
|
|
4affcb72d7 | ||
|
|
38e274d441 |
@@ -14,6 +14,13 @@ interface McpServerConfig {
|
|||||||
type?: string;
|
type?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
headers?: Record<string, string>;
|
headers?: Record<string, string>;
|
||||||
|
openapi?: {
|
||||||
|
url?: string;
|
||||||
|
schema?: Record<string, any>;
|
||||||
|
version?: string;
|
||||||
|
security?: any;
|
||||||
|
passthroughHeaders?: string[];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportJsonFormat {
|
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 => {
|
const parseAndValidateJson = (input: string): ImportJsonFormat | null => {
|
||||||
@@ -89,15 +124,34 @@ HTTP example:
|
|||||||
// Normalize config to MCPHub format
|
// Normalize config to MCPHub format
|
||||||
const normalizedConfig: any = {};
|
const normalizedConfig: any = {};
|
||||||
|
|
||||||
|
// Handle different server types
|
||||||
if (config.type === 'sse' || config.type === 'streamable-http') {
|
if (config.type === 'sse' || config.type === 'streamable-http') {
|
||||||
|
// SSE and streamable-http servers use top-level url
|
||||||
normalizedConfig.type = config.type;
|
normalizedConfig.type = config.type;
|
||||||
normalizedConfig.url = config.url;
|
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) {
|
if (config.headers) {
|
||||||
normalizedConfig.headers = config.headers;
|
normalizedConfig.headers = config.headers;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Default to stdio
|
// Command-based servers (stdio or unspecified type)
|
||||||
normalizedConfig.type = 'stdio';
|
normalizedConfig.type = config.type || 'stdio';
|
||||||
normalizedConfig.command = config.command;
|
normalizedConfig.command = config.command;
|
||||||
normalizedConfig.args = config.args || [];
|
normalizedConfig.args = config.args || [];
|
||||||
if (config.env) {
|
if (config.env) {
|
||||||
@@ -238,6 +292,16 @@ HTTP example:
|
|||||||
<strong>{t('server.url')}:</strong> {server.config.url}
|
<strong>{t('server.url')}:</strong> {server.config.url}
|
||||||
</div>
|
</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 && (
|
{server.config.env && Object.keys(server.config.env).length > 0 && (
|
||||||
<div>
|
<div>
|
||||||
<strong>{t('server.envVars')}:</strong>{' '}
|
<strong>{t('server.envVars')}:</strong>{' '}
|
||||||
|
|||||||
Reference in New Issue
Block a user