Fluent builder for registering a Model Context Protocol server contributed by an app, reached from controllerMappings.websiteMcpController for a server exposed to AI clients on public websites, or controllerMappings.adminMcpController for one exposed in the admin console. Set the server type, name, version and instructions, register one or more tools with tool, then call build to create the mapping and, unless the app engine has already finished initialising, register it for routing.
Group: Builders
Methods
type(String type) · serverName(String serverName) · serverVersion(String serverVersion) · instructions(String instructions) · tool(Map<String,Object> spec) · toolFunction(String toolFunction) · isPublic(boolean isPublic) · addRole(String roleNames) · build()
type(String type)
Returns: McpMappingBuilder
Sets the mapping's type, which is used as the URL segment and lookup key for this MCP server.
| Parameter | Description |
|---|---|
type | the server type |
serverName(String serverName)
Returns: McpMappingBuilder
Sets the server name reported to MCP clients.
| Parameter | Description |
|---|---|
serverName | the server name |
serverVersion(String serverVersion)
Returns: McpMappingBuilder
Sets the server version reported to MCP clients.
| Parameter | Description |
|---|---|
serverVersion | the server version |
instructions(String instructions)
Returns: McpMappingBuilder
Sets the usage instructions reported to MCP clients, describing how to use this server's tools.
| Parameter | Description |
|---|---|
instructions | the instructions text |
tool(Map<String,Object> spec)
Returns: McpMappingBuilder
Registers a tool from a spec object mirroring the MCP Tool wire format (name, description, inputSchema, outputSchema, title, annotations, icons, _meta, and so on) plus functionName, the global JS function to invoke for calls. The spec is serialised to JSON immediately, while the JS context is still executing, so it remains readable afterwards.
| Parameter | Description |
|---|---|
spec | the tool spec; functionName and name are required |
toolFunction(String toolFunction)
Returns: McpMappingBuilder
Sets the name of a JS function invoked, before an individual tool's own function, whenever any tool on this server is called.
| Parameter | Description |
|---|---|
toolFunction | the JS function name |
isPublic(boolean isPublic)
Returns: McpMappingBuilder
Sets whether this MCP server can be called without authentication.
| Parameter | Description |
|---|---|
isPublic | true to allow anonymous access, false to require authentication |
addRole(String roleNames)
Returns: McpMappingBuilder
Restricts access to this MCP server to callers holding at least one of the given role names.
| Parameter | Description |
|---|---|
roleNames | the role names to grant access, ignored if null or empty |
build()
Returns: RepoAppMcpMapping
Builds the MCP mapping from the values set on this builder and, unless the app engine has already finished initialising, registers it for routing.