Skip to content

server

server

Standalone crew-dcs FastMCP v3 server.

Builds a FastMCP server whose tools are crew-dcs callables wrapped by the generic factory. Auth is supplied by an injected resolver (default: env-based single-instance). Run with: uv run python -m crew_dcs.mcp_server.server.

build_server

build_server(
    auth_resolver: AuthResolver = env_auth_resolver,
    *,
    primary_only: bool = False,
    auth=None
) -> FastMCP

Construct the crew-dcs MCP server with the injected auth resolver.

primary_only=True advertises only the primary tier by default (the disclosure posture for deployment); secondary tools stay registered and are revealed per-session via reveal_toolset. auth is a FastMCP auth provider (e.g. JWTVerifier) for token validation at the server boundary.

Source code in src/crew_dcs/mcp_server/server.py
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
def build_server(
    auth_resolver: AuthResolver = env_auth_resolver,
    *,
    primary_only: bool = False,
    auth=None,
) -> FastMCP:
    """Construct the crew-dcs MCP server with the injected auth resolver.

    primary_only=True advertises only the primary tier by default (the disclosure
    posture for deployment); secondary tools stay registered and are revealed
    per-session via reveal_toolset. `auth` is a FastMCP auth provider (e.g.
    JWTVerifier) for token validation at the server boundary.
    """
    mcp = FastMCP(name="crew-dcs", auth=auth)
    tools: list = []

    def _reg(tool):
        tools.append(tool)
        mcp.add_tool(tool)

    _reg(
        make_tool(
            DomoUser.get_by_id,
            auth_resolver,
            name="get_user",
            tags={"user", "primary"},
            annotations=ToolAnnotations(readOnlyHint=True),
        )
    )
    _reg(
        make_tool(
            get_roles_with_membership,
            auth_resolver,
            name="get_roles_with_membership",
            tags={"role", "primary"},
            annotations=ToolAnnotations(readOnlyHint=True),
        )
    )
    _reg(
        make_tool(
            update_users_role,
            auth_resolver,
            name="update_users_role",
            tags={"user", "primary"},
            annotations=ToolAnnotations(destructiveHint=True),
        )
    )
    # Auto-register entity classmethod factories (comprehensive coverage, secondary tier).
    for cls, tag, manifest in _AUTO_ENTITIES:
        tools.extend(
            register_entity_class(mcp, cls, auth_resolver, tag=tag, manifest=manifest)
        )

    # Meta tools (always primary). Catalog captured over the full tool set so it
    # advertises every class regardless of later visibility filtering.
    catalog = build_capabilities_catalog(tools)
    _reg(
        Tool.from_function(
            _list_instances, name="list_my_domo_instances", tags={"meta", "primary"}
        )
    )
    _reg(
        Tool.from_function(
            make_list_capabilities(catalog),
            name="list_domo_capabilities",
            tags={"meta", "primary"},
        )
    )
    _reg(
        Tool.from_function(
            make_reveal_toolset(tools), name="reveal_toolset", tags={"meta", "primary"}
        )
    )

    if primary_only:
        apply_primary_only(mcp)
    return mcp