@grebyn/toolflow-mcp-server
Version:
MCP server for managing other MCP servers - discover, install, organize into bundles, and automate with workflows. Uses StreamableHTTP transport with dual OAuth/API key authentication.
141 lines (137 loc) • 6.1 kB
JavaScript
import { ApiClient } from '../../utils/api-client.js';
export const listMissingWorkflowServersTool = {
name: 'list_missing_workflow_servers',
description: `Get installation configurations for MCP servers required by a workflow that are missing from the client.
**Expected Workflow:**
1. Call \`perform_workflow\` with a workflow ID → receives list of required servers
2. Check which servers are missing from your target client (compare with installed servers)
3. Call this tool with the specific missing server names → get installation configs
4. Use \`write_client_config\` to install the missing servers
Returns server configurations ready for installation.`,
inputSchema: {
type: 'object',
properties: {
workflow_id: {
type: 'string',
description: 'The workflow ID to get server configurations for'
},
missing_servers: {
type: 'array',
items: { type: 'string' },
description: 'Names of specific servers you need installation configs for. Get these from perform_workflow output (e.g., ["git", "vercel", "filesystem"])'
}
},
required: ['workflow_id', 'missing_servers']
},
async execute(args, context) {
try {
// Fetch the workflow from API
const workflow = await ApiClient.getWorkflow(args.workflow_id, context);
if (!workflow) {
return {
content: [{
type: 'text',
text: `❌ Workflow not found with ID: ${args.workflow_id}. Verify the workflow ID is correct and you have access to it. Use \`list_workflows\` to find available workflows.`
}]
};
}
// API already validated access
const hasAccess = true;
if (!hasAccess) {
return {
content: [{
type: 'text',
text: 'You do not have access to this workflow'
}]
};
}
// No client adaptation - we'll return generic configurations
const useGenericConfig = true;
// Get configurations for missing servers
const requiredServers = workflow.required_servers || {};
const missingConfigs = [];
for (const serverName of args.missing_servers) {
if (requiredServers[serverName]) {
const originalConfig = requiredServers[serverName];
missingConfigs.push({
name: serverName,
config: originalConfig,
adapted_for_client: originalConfig // No adaptation, use original config
});
}
}
if (missingConfigs.length === 0) {
return {
content: [{
type: 'text',
text: 'No configurations found for the specified missing servers.'
}]
};
}
// Format the response
const clientIdentifier = process.env.CLIENT || 'unknown';
return {
content: [{
type: 'text',
text: formatMissingServersConfig(workflow, missingConfigs, clientIdentifier, useGenericConfig)
}]
};
}
catch (error) {
console.error('Error listing missing workflow servers:', error);
return {
content: [{
type: 'text',
text: `An unexpected error occurred: ${error instanceof Error ? error.message : 'Unknown error'}`
}]
};
}
}
};
function formatMissingServersConfig(workflow, missingConfigs, clientType, useGenericConfig = false) {
const configType = useGenericConfig ? ' (generic format)' : '';
let output = `**Missing MCP Servers for Workflow:** ${workflow.name}
**Target Client:** ${clientType}${configType}
**Servers to Install:** ${missingConfigs.length}
`;
// Show each missing server configuration
missingConfigs.forEach((serverConfig, index) => {
output += `**${index + 1}. ${serverConfig.name}**\n`;
// Show adapted configuration
const configLabel = useGenericConfig ? 'Generic configuration' : `Configuration for ${clientType}`;
output += `${configLabel}:\n`;
output += '```json\n';
output += JSON.stringify({
[serverConfig.name]: serverConfig.adapted_for_client
}, null, 2);
output += '\n```\n';
// Check for environment variables
const envVars = serverConfig.config.env || {};
const envKeys = Object.keys(envVars);
if (envKeys.length > 0) {
output += `\n**Required environment variables:**\n`;
envKeys.forEach(key => {
const value = envVars[key];
if (value && value !== '' && !value.includes('YOUR_')) {
output += `• ${key} (already configured)\n`;
}
else {
output += `• ${key} - **NEEDS CONFIGURATION**\n`;
}
});
}
output += '\n';
});
output += `**Next Steps:**
1. Ensure any required API keys/tokens are configured
2. Use \`test_mcp_server\` to verify each server configuration
3. Use \`write_client_config\` to install all servers (preserve existing ones!)
4. Restart ${clientType} if needed
5. Run \`perform_workflow\` again to get the workflow instructions
**Important:** When using write_client_config, make sure to:
- First read the current config with \`read_client_config\`
- Merge the new servers with existing ones
- Test configurations before writing`;
return output;
}
//# sourceMappingURL=listMissingWorkflowServers.js.map