Skip to main content
Glama

magg_add_server

Add and configure a new MCP server to the MAGG meta-MCP server, specifying details like name, source, command, and environment variables for enhanced LLM capabilities.

Instructions

Add a new MCP server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandNoFull command to run (e.g., 'python server.py', 'npx @playwright/mcp@latest')
cwdNoWorking directory (for commands)
enableNoWhether to enable the server immediately (default: True)
envNoEnvironment variables (dict or JSON string)
nameYesUnique server name
notesNoSetup notes
prefixNoTool prefix (defaults to conformed server name)
sourceYesURL of the server package/repository
transportNoTransport-specific configuration (dict or JSON string) Common options for all command-based servers: - `keep_alive` (boolean): Keep the process alive between requests (default: true) Python servers (command="python"): - `python_cmd` (string): Python executable path (default: sys.executable) Node.js servers (command="node"): - `node_cmd` (string): Node executable path (default: "node") NPX servers (command="npx"): - `use_package_lock` (boolean): Use package-lock.json if present (default: true) UVX servers (command="uvx"): - `python_version` (string): Python version to use (e.g., "3.13") - `with_packages` (array): Additional packages to install - `from_package` (string): Install tool from specific package HTTP/SSE servers (uri-based): - `headers` (object): HTTP headers to include - `auth` (string): Authentication method ("oauth" or bearer token) - `sse_read_timeout` (number): Timeout for SSE reads in seconds Examples: - Python: `{"keep_alive": false, "python_cmd": "/usr/bin/python3"}` - UVX: `{"python_version": "3.11", "with_packages": ["requests", "pandas"]}` - HTTP: `{"headers": {"Authorization": "Bearer token123"}, "sse_read_timeout": 30}`
uriNoURI for HTTP servers

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
errorsNo
outputNo

Implementation Reference

  • The core handler function implementing the magg_add_server tool logic: validates parameters, creates ServerConfig, mounts the server if enabled, saves configuration, and returns structured response.
    async def add_server(
        self,
        name: Annotated[str, Field(description="Unique server name")],
        source: Annotated[str, Field(description="URL of the server package/repository")],
        prefix: Annotated[str | None, Field(description="Tool prefix (defaults to conformed server name)")] = None,
        command: Annotated[str | None, Field(
            description="Full command to run (e.g., 'python server.py', 'npx @playwright/mcp@latest')"
        )] = None,
        uri: Annotated[AnyUrl | None, Field(description="URI for HTTP servers")] = None,
        env: Annotated[dict[str, str] | str | None, Field(description="Environment variables (dict or JSON string)")] = None,
        cwd: Annotated[str | None, Field(description="Working directory (for commands)")] = None,
        notes: Annotated[str | None, Field(description="Setup notes")] = None,
        enable: Annotated[bool | None, Field(description="Whether to enable the server immediately (default: True)")] = True,
        transport: Annotated[dict[str, Any] | str | None, Field(
            description=f"Transport-specific configuration (dict or JSON string){TRANSPORT_DOCS}"
        )] = None,
    ) -> MaggResponse:
        """Add a new MCP server."""
        try:
            config = self.config
    
            if name in config.servers:
                return MaggResponse.error(f"Server '{name}' already exists")
    
            actual_command = command
            actual_args = None
            if command:
                parts = shlex.split(command)
                if len(parts) > 1:
                    actual_command = parts[0]
                    actual_args = parts[1:]
                elif len(parts) == 1:
                    actual_command = parts[0]
                    actual_args = None
    
            if cwd:
                validated_dir, error = validate_working_directory(cwd, source)
                if error:
                    return MaggResponse.error(error)
                cwd = validated_dir
    
            try:
                server = ServerConfig(
                    name=name,
                    source=source,
                    prefix=prefix,
                    command=actual_command,
                    args=actual_args,
                    uri=uri,
                    env=json_to_dict(env),
                    cwd=cwd,
                    notes=notes,
                    enabled=enable if enable is not None else True,
                    transport=json_to_dict(transport),
                )
            except ValueError as e:
                return MaggResponse.error(str(e))
    
            mount_success = None
    
            if server.enabled:
                mount_success = await self.server_manager.mount_server(server)
    
                if not mount_success:
                    return MaggResponse.error(f"Failed to mount server '{name}'")
    
            config.add_server(server)
    
            if not self.save_config(config):
                return MaggResponse.error(f"Failed to save configuration for added server '{name}'")
    
            return MaggResponse.success({
                "action": "server_added",
                "server": {
                    "name": server.name,
                    "source": server.source,
                    "prefix": server.prefix,
                    "command": (
                        f"{server.command} {' '.join(server.args) if server.args else ''}".strip()
                        if server.command else None
                    ),
                    "uri": server.uri,
                    "cwd": server.cwd,
                    "notes": server.notes,
                    "enabled": server.enabled,
                    "mounted": mount_success
                }
            })
    
        except Exception as e:
            return MaggResponse.error(f"Failed to add server: {str(e)}")
  • Registers the add_server method as the 'magg_add_server' tool using FastMCP's tool decorator within the MaggServer class initialization.
    def _register_tools(self):
        """Register all Magg management tools programmatically.
        """
        self_prefix_ = self.self_prefix_
    
        tools = [
            (self.add_server, f"{self_prefix_}add_server", None),
            (self.remove_server, f"{self_prefix_}remove_server", None),
            (self.list_servers, f"{self_prefix_}list_servers", None),
            (self.enable_server, f"{self_prefix_}enable_server", None),
            (self.disable_server, f"{self_prefix_}disable_server", None),
            (self.search_servers, f"{self_prefix_}search_servers", None),
            (self.smart_configure, f"{self_prefix_}smart_configure", None),
            (self.analyze_servers, f"{self_prefix_}analyze_servers", None),
            (self.status, f"{self_prefix_}status", None),
            (self.check, f"{self_prefix_}check", None),
            (self.reload_config_tool, f"{self_prefix_}reload_config", None),
            (self.load_kit, f"{self_prefix_}load_kit", None),
            (self.unload_kit, f"{self_prefix_}unload_kit", None),
            (self.list_kits, f"{self_prefix_}list_kits", None),
            (self.kit_info, f"{self_prefix_}kit_info", None),
        ]
    
        def call_tool_wrapper(func):
            @wraps(func)
            async def wrapper(*args, **kwds):
                result = await func(*args, **kwds)
    
                if isinstance(result, MaggResponse):
                    return result.as_json_text_content
    
                return result
    
            return wrapper
    
        for method, tool_name, options in tools:
            self.mcp.tool(name=tool_name, **(options or {}))(call_tool_wrapper(method))
    
        self._register_resources()
        self._register_prompts()
  • Defines the detailed tool schema, parameter descriptions, types, and usage examples for magg_add_server, used in tool documentation and LLM prompts.
    MAGG_ADD_SERVER_DOC = """
    Tool: magg_add_server
    
    Description:
      Add a new MCP server.
    
    Parameters:
      name (string) (required)
        Unique server name
      source (string) (required)
        URL of the server package/repository
      prefix (string | null) (optional)
        Tool prefix (defaults to conformed server name)
      command (string | null) (optional)
        Full command to run (e.g., 'python server.py', 'npx @playwright/mcp@latest')
        NOTE: This should include the full command, not just the executable name.
              Arguments will be split automatically.
      uri (string | null) (optional)
        URI for HTTP servers
      env (object | string | null) (optional)
        Environment variables (dict or JSON string)
      cwd (string | null) (optional)
        Working directory (for commands)
      notes (string | null) (optional)
        Setup notes
      enable (boolean | null) (optional)
        Whether to enable the server immediately (default: True)
      transport (object | string | null) (optional)
        Transport-specific configuration (dict or JSON string)
        Common options for all command-based servers:
        - `keep_alive` (boolean): Keep the process alive between requests (default: true)
    
        Python servers (command="python ..."):
        - `python_cmd` (string): Python executable path (default: sys.executable)
    
        Node.js servers (command="node ..."):
        - `node_cmd` (string): Node executable path (default: "node")
    
        NPX servers (command="npx ..."):
        - `use_package_lock` (boolean): Use package-lock.json if present (default: true)
    
        UVX servers (command="uvx ..."):
        - `python_version` (string): Python version to use (e.g., "3.11")
        - `with_packages` (array): Additional packages to install
        - `from_package` (string): Install tool from specific package
    
        HTTP/SSE servers (uri-based):
        - `headers` (object): HTTP headers to include
        - `auth` (string): Authentication method ("oauth" or bearer token)
        - `sse_read_timeout` (number): Timeout for SSE reads in seconds
    
        Examples:
        - Python: `{"keep_alive": false, "python_cmd": "/usr/bin/python3"}`
        - UVX: `{"python_version": "3.11", "with_packages": ["requests", "pandas"]}`
        - HTTP: `{"headers": {"Authorization": "Bearer token123"}, "sse_read_timeout": 30}`
    
    Example configurations arguments:
    [
        "calc": {
          "name": "Calculator MCP",
          "source": "https://github.com/wrtnlabs/calculator-mcp",
          "prefix": "calc",
          "command": "npx -y @wrtnlabs/calculator-mcp@latest"
        },
        "playwright": {
          "name": "Playwright MCP",
          "source": "https://github.com/microsoft/playwright-mcp",
          "prefix": "playwright",
          "notes": "Browser automation MCP server using Playwright.",
          "command": "npx @playwright/mcp@latest"
        },
        "test": {
          "name": "test",
          "source": "play",
          "command": "python play/test_server.py"
        },
        "hello": {
          "name": "hello",
          "source": "https://www.npmjs.com/package/mcp-hello-world",
          "command": "npx mcp-hello-world@latest"
        }
    ]
    """
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but only states the basic action. It doesn't mention whether this is a persistent configuration change, what permissions are required, whether the server starts immediately, how errors are handled, or what the typical response looks like. For a complex 10-parameter tool with mutation implications, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with zero wasted words. It's perfectly front-loaded with the core action and resource, making it immediately scannable and efficient. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (10 parameters, mutation operation, no annotations) and the existence of an output schema, the description is insufficient. It doesn't explain the relationship between command/uri parameters, doesn't mention that this likely creates persistent configuration, and provides no context about what 'adding' entails in this system. The output schema helps with return values, but the description should do more to contextualize this significant operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 100% description coverage, so all parameters are documented in the schema itself. The description adds no additional parameter context beyond the tool's name, which implies all parameters relate to server addition. This meets the baseline expectation when schema coverage is complete, but doesn't enhance understanding of how parameters interact or typical usage patterns.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Add') and resource ('MCP server'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its sibling 'magg_smart_configure' which might also involve server configuration, nor does it specify what type of MCP server is being added (e.g., command-based vs. HTTP).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'magg_smart_configure' or 'magg_load_kit'. It doesn't mention prerequisites, dependencies, or typical scenarios for adding a server versus using other configuration methods. The agent must infer usage from parameter names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/sitbon/magg'

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