Skip to main content
Glama
landicefu

MCP Client Configuration Server

by landicefu

get_server_configuration

Retrieve server configuration details for AI assistant clients to manage and synchronize MCP server settings across different platforms.

Instructions

Get the configuration for a specific server from a client configuration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clientYesClient name (cline, roo_code, windsurf, claude)
server_nameYesName of the server to retrieve

Implementation Reference

  • Executes the get_server_configuration tool: validates client and server_name, reads client config file, extracts and returns the server configuration as JSON.
    case 'get_server_configuration': {
      const client = validateClient(args.client);
      const serverName = args.server_name;
      
      if (typeof serverName !== 'string') {
        throw new McpError(ErrorCode.InvalidParams, 'server_name must be a string');
      }
      
      const configPath = getConfigPath(client);
      
      let config;
      try {
        config = await readConfigFile(configPath);
      } catch (error) {
        if (error instanceof McpError && error.code === ErrorCode.InternalError && error.message.includes('not found')) {
          throw new McpError(ErrorCode.InvalidParams, `Server '${serverName}' not found in ${client} configuration (configuration file does not exist)`);
        } else {
          throw error;
        }
      }
      
      // Check if the server exists
      if (!config.mcpServers || !config.mcpServers[serverName]) {
        throw new McpError(ErrorCode.InvalidParams, `Server '${serverName}' not found in ${client} configuration`);
      }
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(config.mcpServers[serverName], null, 2),
          },
        ],
      };
    }
  • Input schema for get_server_configuration tool, defining parameters client (string) and server_name (string), both required.
    {
      name: 'get_server_configuration',
      description: 'Get the configuration for a specific server from a client configuration',
      inputSchema: {
        type: 'object',
        properties: {
          client: {
            type: 'string',
            description: 'Client name (cline, roo_code, windsurf, claude)',
          },
          server_name: {
            type: 'string',
            description: 'Name of the server to retrieve',
          },
        },
        required: ['client', 'server_name'],
      },
    },
  • src/index.ts:125-233 (registration)
    Registers the get_server_configuration tool by including it in the tools list returned for ListToolsRequest.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: 'get_configuration_path',
          description: 'Get the path to the configuration file for a specific client',
          inputSchema: {
            type: 'object',
            properties: {
              client: {
                type: 'string',
                description: 'Client name (cline, roo_code, windsurf, claude)',
              },
            },
            required: ['client'],
          },
        },
        {
          name: 'get_configuration',
          description: 'Get the entire configuration for a specific client',
          inputSchema: {
            type: 'object',
            properties: {
              client: {
                type: 'string',
                description: 'Client name (cline, roo_code, windsurf, claude)',
              },
            },
            required: ['client'],
          },
        },
        {
          name: 'list_servers',
          description: 'List all server names configured in a specific client',
          inputSchema: {
            type: 'object',
            properties: {
              client: {
                type: 'string',
                description: 'Client name (cline, roo_code, windsurf, claude)',
              },
            },
            required: ['client'],
          },
        },
        {
          name: 'get_server_configuration',
          description: 'Get the configuration for a specific server from a client configuration',
          inputSchema: {
            type: 'object',
            properties: {
              client: {
                type: 'string',
                description: 'Client name (cline, roo_code, windsurf, claude)',
              },
              server_name: {
                type: 'string',
                description: 'Name of the server to retrieve',
              },
            },
            required: ['client', 'server_name'],
          },
        },
        {
          name: 'add_server_configuration',
          description: 'Add or update a server configuration in a client configuration',
          inputSchema: {
            type: 'object',
            properties: {
              client: {
                type: 'string',
                description: 'Client name (cline, roo_code, windsurf, claude)',
              },
              server_name: {
                type: 'string',
                description: 'Name of the server to add or update',
              },
              json_config: {
                type: 'object',
                description: 'Server configuration in JSON format',
              },
              allow_override: {
                type: 'boolean',
                description: 'Whether to allow overriding an existing server configuration with the same name (default: false)',
                default: false,
              },
            },
            required: ['client', 'server_name', 'json_config'],
          },
        },
        {
          name: 'remove_server_configuration',
          description: 'Remove a server configuration from a client configuration',
          inputSchema: {
            type: 'object',
            properties: {
              client: {
                type: 'string',
                description: 'Client name (cline, roo_code, windsurf, claude)',
              },
              server_name: {
                type: 'string',
                description: 'Name of the server to remove',
              },
            },
            required: ['client', 'server_name'],
          },
        },
      ],
    }));
  • Helper function to validate the client parameter used in get_server_configuration.
    const validateClient = (client: unknown): ClientType => {
      if (typeof client !== 'string') {
        throw new McpError(ErrorCode.InvalidParams, 'Client must be a string');
      }
      
      const validClients: ClientType[] = ['cline', 'roo_code', 'windsurf', 'claude'];
      if (!validClients.includes(client as ClientType)) {
        throw new McpError(ErrorCode.InvalidParams, `Invalid client: ${client}. Must be one of: ${validClients.join(', ')}`);
      }
      
      return client as ClientType;
    };
  • Helper function to read and parse the client configuration JSON file, used by get_server_configuration.
    const readConfigFile = async (configPath: string): Promise<any> => {
      try {
        const data = await fs.readFile(configPath, 'utf8');
        return JSON.parse(data);
      } catch (error: unknown) {
        if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
          throw new McpError(ErrorCode.InternalError, `Configuration file not found: ${configPath}`);
        }
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new McpError(ErrorCode.InternalError, `Error reading configuration file: ${errorMessage}`);
      }
    };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/landicefu/mcp-client-configuration-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server