C3 AI Documentation Home

Use Tools, Prompts, and Resources from an MCP Client

After you register an MCP client, six methods on GenaiCore.Mcp.Client let you discover and invoke whatever the connected server exposes.

Each method resolves auth headers internally from the client's config, so non-admin users can call them without direct access to the secret config.

Capability matrix

OperationMethodReturnsMCP endpoint
Discover toolslistTools(include)[GenaiCore.Tool.Mcp]tools/list
Call a toolcallTool(toolName, args)jsontools/call
Refresh persisted toolsrefreshToolDefinitions()(void)tools/list
Discover promptslistPrompts(include)[GenaiCore.Prompt.Mcp]prompts/list
Get a promptgetPrompt(promptName, args)jsonprompts/get
Discover resourceslistResources(include)[GenaiCore.Resource.Mcp]resources/list
Read a resourcereadResource(uri)jsonresources/read

The include parameter on each list* method is an optional filter of names (or URIs, for resources). If omitted, the call returns every item the server exposes.

Tools

List tools

Python
client = c3.GenaiCore.Mcp.Client.forName("example-mcp")
tools = client.listTools()  # all tools
weather_tools = client.listTools(include=["forecast", "current_conditions"])

listTools calls the server's tools/list endpoint and returns a list of GenaiCore.Tool.Mcp. The returned list may differ from the GenaiCore.Tool.Mcp records persisted in the database if the MCP server has been updated since the last refresh.

Call a tool

Python
result = client.callTool(
    toolName="forecast",
    args={"city": "San Francisco", "days": 3},
)

callTool calls the server's tools/call endpoint with the given arguments. The return value follows the structure defined by the MCP protocol's tool call structure.

Refresh persisted tool definitions

Python
client.refreshToolDefinitions()

refreshToolDefinitions updates persisted GenaiCore.Tool.Mcp associated with this client. It does not create new tools or delete tools that no longer exist on the server. It only updates the records that are already there.

Prompts

listPrompts and getPrompt expose the MCP server's prompt templates as GenaiCore.Prompt.Mcp objects.

List prompts

Python
prompts = client.listPrompts()
filtered = client.listPrompts(include=["summarize", "translate"])

listPrompts calls the server's prompts/list endpoint.

Get a prompt

Python
rendered = client.getPrompt(
    promptName="summarize",
    args={"text": "...", "max_words": 100},
)

getPrompt calls the server's prompts/get endpoint. The returned JSON contains the rendered prompt messages.

Resources

listResources and readResource expose the MCP server's resources as GenaiCore.Resource.Mcp objects.

List resources

Python
resources = client.listResources()
filtered = client.listResources(include=["file:///docs/readme.md"])

listResources calls the server's resources/list endpoint.

Read a resource

Python
content = client.readResource(uri=c3.Url(value="file:///docs/readme.md"))

readResource calls the server's resources/read endpoint and returns JSON containing the resource contents and a resourceUri field.

Authentication is resolved internally

Every capability method reads the auth headers from the client's secret config (GenaiCore.Mcp.Client.Shared.Config.headers for shared clients, GenaiCore.Mcp.Client.User.Config.headers for user clients) at call time. Callers do not need permission to read the secret config directly. This makes the methods safe to call from non-admin user contexts.

Discover an authorization server

When a server requires OAuth and you want C3 to find the authorization server for you, call discoverAuthorizationServer:

Python
metadata = client.discoverAuthorizationServer(
    resourceServerUrl="https://mcp.example.com/server",
    name="example-auth-server",
    failIfNotDiscovered=True,
)

The method tries well-known discovery URLs and the optional RFC 9728 WWW-Authenticate resource metadata URL. The returned JSON includes name, discoveryUrl, tokenEndpoint, authorizationEndpoint, and optional revocationEndpoint and registrationEndpoint fields.

For the full OAuth walkthrough, see Connect a User to an MCP Server with OAuth 2.0 PKCE.

See also

Was this page helpful?