io.enterpriseai.resources.McpClient
Source: sdks/java/enterprise-ai-java/src/main/java/io/enterpriseai/resources/McpClient.java. Back to the Java SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Class McpClient
MCP servers and JSON-RPC 2.0 gateway.
Constructor McpClient
McpClient(Transport transport)
Creates the client on the shared transport; EnterpriseAIClient builds it and exposes it through the accessor of the same name.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
transport | Transport | yes | Transport shared by the sub-clients of one client. |
McpClient.catalog
JsonNode catalog()
Get the MCP tool catalogue. Catalogue: tools, input and output schemas, versions, scopes and approval status (approved, pending_approval, rejected), for the servers the request may see only, as GET /v1/mcp/servers.
Route: /v1/mcp/catalog (GET).
This element takes no parameter.
Returns: JsonNode. Decoded JSON answer of the operation "Get the MCP tool catalogue".
Raises: the typed errors of the transport (Errors).
McpClient.catalog
JsonNode catalog(Map<String, ?> query)
Get the MCP tool catalogue. Catalogue: tools, input and output schemas, versions, scopes and approval status (approved, pending_approval, rejected), for the servers the request may see only, as GET /v1/mcp/servers.
Route: /v1/mcp/catalog (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
query | Map<String, ?> | yes | Query string parameters of the route. |
Returns: JsonNode. Decoded JSON answer of the operation "Get the MCP tool catalogue".
Raises: the typed errors of the transport (Errors).
McpClient.createServer
JsonNode createServer(Object body)
Register an MCP server. Registers an upstream server (201). The URL must be http(s) on an internal host allowed by the MCP egress policy (403 mcp_online_forbidden otherwise); bearer, api_key and query_param need an openbao:// or env:// credential_ref, query_param needs param, connector needs connector (400 invalid_request). A name already used answers 409 conflict. The project (default X-Project) must be the request project (403 mcp_project_forbidden). Needs tenant_admin, developer or application_owner; the caller becomes ReBAC owner. Audited as mcp.server.create.
Route: /v1/mcp/servers (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Name, URL, transport, upstream authentication, allow lists, owner and project. |
Returns: JsonNode. Decoded JSON answer of the operation "Register an MCP server".
Raises: the typed errors of the transport (Errors).
McpClient.createServer
JsonNode createServer(Object body, RequestOptions options)
Register an MCP server. Registers an upstream server (201). The URL must be http(s) on an internal host allowed by the MCP egress policy (403 mcp_online_forbidden otherwise); bearer, api_key and query_param need an openbao:// or env:// credential_ref, query_param needs param, connector needs connector (400 invalid_request). A name already used answers 409 conflict. The project (default X-Project) must be the request project (403 mcp_project_forbidden). Needs tenant_admin, developer or application_owner; the caller becomes ReBAC owner. Audited as mcp.server.create.
Route: /v1/mcp/servers (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Name, URL, transport, upstream authentication, allow lists, owner and project. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Register an MCP server".
Raises: the typed errors of the transport (Errors).
McpClient.deleteServer
void deleteServer(String id)
Delete an MCP server. Removes the server from the registry. Needs tenant_admin, the ReBAC relation owner and access to the project of the server. 404 mcp_server_not_found. Audited as mcp.server.delete.
Route: /v1/mcp/servers/{server_id} (DELETE).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id | String | yes | Identifier (UUID) or name of the MCP server. |
Returns: void.
Raises: the typed errors of the transport (Errors).
McpClient.discover
JsonNode discover(String serverId)
Discover the tools of an MCP server. MCP protocol discovery (initialize, tools/list): every new or changed tool schema becomes a catalogue version waiting for approval (mcp_tool_version, approvers tenant_admin or security_officer). Returns the versions created with their approval ids. Needs tenant_admin, developer or application_owner, the ReBAC relation editor and access to the project of the server.
Route: /v1/mcp/servers/{server_id}/discover (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
serverId | String | yes | Identifier (UUID) or name of the MCP server. |
Returns: JsonNode. Decoded JSON answer of the operation "Discover the tools of an MCP server".
Raises: the typed errors of the transport (Errors).
McpClient.discover
JsonNode discover(String serverId, RequestOptions options)
Discover the tools of an MCP server. MCP protocol discovery (initialize, tools/list): every new or changed tool schema becomes a catalogue version waiting for approval (mcp_tool_version, approvers tenant_admin or security_officer). Returns the versions created with their approval ids. Needs tenant_admin, developer or application_owner, the ReBAC relation editor and access to the project of the server.
Route: /v1/mcp/servers/{server_id}/discover (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
serverId | String | yes | Identifier (UUID) or name of the MCP server. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Discover the tools of an MCP server".
Raises: the typed errors of the transport (Errors).
McpClient.listServers
Page<JsonNode> listServers()
List the MCP servers. Servers the request may see: project (id or slug) keeps the servers of that project; a request made in a project (X-Project header or an API key bound to a project) sees the servers of its project and those shared by the tenant, never those of another project (403 mcp_project_forbidden). Upstream secrets are never returned, only their references.
Route: /v1/mcp/servers (GET).
This element takes no parameter.
Returns: Page<JsonNode>. A Page: One page of a cursor paginated collection ({"items": [...], "next_cursor": "..."|null}).
Raises: the typed errors of the transport (Errors).
McpClient.rpc
JsonNode rpc(String serverId, Object body)
Call an MCP server through the gateway. JSON-RPC 2.0 proxy. The body is one request or a batch (at most 50 are handled). Needs tenant_admin, developer or agent and the ReBAC relation can_invoke. Refusals are answered as JSON-RPC errors with HTTP 200, and audited. Checks, in order: valid JSON-RPC 2.0; server active; project isolation (mcp_server_project_mismatch); allowed callers (mcp_principal_not_allowed); a sleeping hosted instance is woken up; a third party application must be active and granted the server; method allowed; for tools/call: tool in allowed_tools, scope tools:invoke, DLP on the arguments; policy mcp.call; quota reservation; for resources/read: URI in allowed_resources. Then the call is forwarded with the upstream credentials; tools/list and resources/list are filtered by the allow lists, tools/call results are masked by DLP and screened for prompt injection, and the call is metered as a tool usage.
Route: /v1/mcp/gateway/{server_id} (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
serverId | String | yes | Identifier (UUID) or name of the MCP server. | |
body | Object | yes | A JSON-RPC 2.0 request (jsonrpc, id, method, params) or an array of requests. |
Returns: JsonNode. Decoded JSON answer of the operation "Call an MCP server through the gateway".
Raises: the typed errors of the transport (Errors).
McpClient.rpc
JsonNode rpc(String serverId, Object body, RequestOptions options)
Call an MCP server through the gateway. JSON-RPC 2.0 proxy. The body is one request or a batch (at most 50 are handled). Needs tenant_admin, developer or agent and the ReBAC relation can_invoke. Refusals are answered as JSON-RPC errors with HTTP 200, and audited. Checks, in order: valid JSON-RPC 2.0; server active; project isolation (mcp_server_project_mismatch); allowed callers (mcp_principal_not_allowed); a sleeping hosted instance is woken up; a third party application must be active and granted the server; method allowed; for tools/call: tool in allowed_tools, scope tools:invoke, DLP on the arguments; policy mcp.call; quota reservation; for resources/read: URI in allowed_resources. Then the call is forwarded with the upstream credentials; tools/list and resources/list are filtered by the allow lists, tools/call results are masked by DLP and screened for prompt injection, and the call is metered as a tool usage.
Route: /v1/mcp/gateway/{server_id} (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
serverId | String | yes | Identifier (UUID) or name of the MCP server. | |
body | Object | yes | A JSON-RPC 2.0 request (jsonrpc, id, method, params) or an array of requests. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Call an MCP server through the gateway".
Raises: the typed errors of the transport (Errors).
McpClient.serverTools
JsonNode serverTools(String id)
List the tools of an MCP server. Calls tools/list on the server through the gateway and returns the tools allowed by allowed_tools. Needs the ReBAC relation can_invoke and access to the project of the server. An upstream error answers 502 upstream_error.
Route: /v1/mcp/servers/{server_id}/tools (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id | String | yes | Identifier (UUID) or name of the MCP server. |
Returns: JsonNode. Decoded JSON answer of the operation "List the tools of an MCP server".
Raises: the typed errors of the transport (Errors).
McpClient.setAccess
JsonNode setAccess(String serverId, Object body)
Set who may call an MCP server. MCP Gateway access control: which users and agents may call this server; an empty list lets every member of its project call it. Principal ids are letters, digits and :._@/- (up to 128 characters, 400 invalid_request). The access of a hosted instance is managed by the MCP runtime (409 mcp_instance_access_managed). Needs tenant_admin, developer or application_owner and access to the project of the server. Audited as mcp.server.access.
Route: /v1/mcp/servers/{server_id}/access (PUT).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
serverId | String | yes | Identifier (UUID) or name of the MCP server. | |
body | Object | yes | The allowed principals. |
Returns: JsonNode. Decoded JSON answer of the operation "Set who may call an MCP server".
Raises: the typed errors of the transport (Errors).
McpClient.setServerStatus
JsonNode setServerStatus(String id, Object body)
Enable or disable an MCP server. active goes through a promotion: an approval is opened and the answer is 202 with approval_id. disabled applies at once (every gateway call is then refused) and is audited as mcp.server.status. Needs tenant_admin or security_officer, the ReBAC relation editor and access to the project of the server.
Route: /v1/mcp/servers/{server_id}/status (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id | String | yes | Identifier (UUID) or name of the MCP server. | |
body | Object | yes | Target status and reason. |
Returns: JsonNode. Decoded JSON answer of the operation "Enable or disable an MCP server".
Raises: the typed errors of the transport (Errors).
McpClient.setServerStatus
JsonNode setServerStatus(String id, Object body, RequestOptions options)
Enable or disable an MCP server. active goes through a promotion: an approval is opened and the answer is 202 with approval_id. disabled applies at once (every gateway call is then refused) and is audited as mcp.server.status. Needs tenant_admin or security_officer, the ReBAC relation editor and access to the project of the server.
Route: /v1/mcp/servers/{server_id}/status (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id | String | yes | Identifier (UUID) or name of the MCP server. | |
body | Object | yes | Target status and reason. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Enable or disable an MCP server".
Raises: the typed errors of the transport (Errors).
McpClient.syncHosted
JsonNode syncHosted(String project)
Publish the MCP servers hosted by the Navin Manager. Publishes the MCP servers hosted by the Navin Manager (service mcp-host) in their project: token kept in the Credential Broker, server of the project created or updated, servers no longer hosted disabled. project (id or slug, default the request project) limits the synchronisation to one project; a project other than the request one answers 403 mcp_project_forbidden. Needs tenant_admin and a tenant (403 tenant_required).
Route: /v1/mcp/hosted/sync (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
project | String | yes | Identifier (UUID) or slug of the only project to synchronise. Default: the project of the request. |
Returns: JsonNode. Decoded JSON answer of the operation "Publish the MCP servers hosted by the Navin Manager".
Raises: the typed errors of the transport (Errors).