Building an Agent Against the ChartHop MCP Server
Building an Agent Against the ChartHop MCP Server
This guide is for developers connecting an AI agent to ChartHop over the Model Context Protocol (MCP). It covers how to connect and authenticate, what tools are available, how to call them, and the security model you're operating inside.
If you're using a supported MCP client (Claude, ChatGPT connectors, Cursor, etc.), most of the OAuth handshake is automatic - you paste a URL and approve a consent screen. If you're building a client from scratch, the Connecting section documents the full flow.
TL;DR
- Transport: JSON-RPC 2.0 over HTTP POST (Streamable HTTP). Request/response only (no SSE stream).
- Auth: OAuth 2.0 with PKCE and dynamic client identification (CIMD). You end up with a Bearer token scoped to one agent and one org.
- Connection URL: https://<host>/mcp/{agent} (org chosen at consent time) or https://<host>/mcp/{agent}/{orgId} (org fixed in the URL).
- Tools: Five: Search, List, Detail, Me (all read-only), and AskAgent (delegate a task to a ChartHop agent).
- Writes: Off by default. The four data-access tools are read-only by design; actual mutation happens only through AskAgent with readOnly: false, and only when the agent install has writes enabled. See Permissions and Write Access for the full checklist.
Connecting
Connection URL shapes
There are two URL patterns. {agent} is the slug of the ChartHop AI agent you're connecting to (an org can publish more than one agent).
Pattern | When to use |
|---|---|
POST /mcp/{agent} | Org-less. The org is selected during the OAuth consent step. Use this for marketplace or directory listings where the URL can't hardcode a customer. |
POST /mcp/{agent}/{orgId} | Org-scoped. The org is fixed in the URL. {orgId} may be an org id or slug. |
GET on either path returns 405 Method Not Allowed - the server does not offer an SSE stream. All traffic is request/response POST.
The OAuth flow
ChartHop implements OAuth 2.0 with PKCE (S256, mandatory) and CIMD (client identification by metadata document) instead of pre-registered client secrets. Your client is identified by a URL to a hosted client-metadata document rather than a client_id/client_secret you register ahead of time.
A compliant MCP client performs these steps automatically. In order:
1. Discover the authorization server. Starting from just the MCP URL, fetch the protected-resource metadata (RFC 9728):
GET /.well-known/oauth-protected-resource/mcp/{agent}[/{orgId}]
-> { resource, authorization_servers, bearer_methods_supported }Then the authorization-server metadata (RFC 8414) at the advertised location:
GET /.well-known/oauth-authorization-server/mcp/{agent}[/{orgId}]2. Fetch grant info for the consent screen:
GET /oauth/mcp/grant-info?clientId=<CIMD_URL>&resource=<resource>&redirectUri=<redirect>- clientId - the URL of your hosted client-metadata document (e.g. https://claude.ai/.well-known/oauth-client-metadata.json).
- resource - the MCP server URL being authorized (RFC 8707).
- The response describes your client, the signed-in user, and - for an org-less URL - the list of candidate orgs the user can pick from.
3. User approves. The ChartHop consent screen posts the approval:
POST /oauth/mcp/approve
{
"clientId": "<CIMD_URL>",
"redirectUri": "<redirect>",
"codeChallenge": "<S256 hash>",
"codeChallengeMethod": "S256",
"resource": "<resource URL>",
"state": "<opaque>",
"orgId": "<selected org>"
}
-> { "redirectUrl": "<redirect>?code=...&state=...&iss=..." }The authorization code is bound to the user, agent, org, PKCE challenge, and redirect URI, and carries the MCP and SENSITIVE scopes.
4. Exchange the code for an access token (PKCE verifier required):
POST /oauth/token
grant_type=authorization_code
code=<code>
client_id=<CIMD_URL>
redirect_uri=<redirect>
code_verifier=<PKCE verifier>
resource=<resource URL>
-> { "access_token": "...", "token_type": "bearer", "expires_in": ... }The CIMD document at clientId is validated server-side: HTTPS only, no redirects, size-capped, fetched through an egress proxy (SSRF protection), and the redirect_uri must be listed in it. Loopback redirect URIs match with port flexibility per RFC 8252 so native clients can use an ephemeral local port.
Using the token
Send it as a bearer token on every MCP request:
Authorization: Bearer <access_token>The token is audience-bound to the agent and org-bound. A token minted for one agent/org cannot be replayed against another. The SENSITIVE scope controls whether sensitive fields (e.g. compensation) come back unmasked - subject to the agent's own permissions.
The protocol
Versions
The server speaks multiple MCP protocol versions and negotiates per client:
Version | Notes |
|---|---|
2026-07-28 | Newest. Stateless: declared per-request (see below), no initialize handshake. |
2025-06-18 | Latest legacy version. No JSON-RPC batching. |
2025-03-26 | Legacy. Supports batching. |
2024-11-05 | Legacy. Supports batching. |
Legacy clients send an initialize request; the server replies with the negotiated protocolVersion, capabilities, and serverInfo, and you send an MCP-Protocol-Version header on subsequent requests. If a legacy initialize asks for 2026-07-28, it's clamped down to the latest legacy version.
Stateless (2026-07-28) clients skip initialize entirely and declare the version on each request under params._meta["io.modelcontextprotocol/protocolVersion"]. Discover support with the server/discover method, which returns supportedVersions (newest first).
Content type
The message endpoint accepts any Content-Type - some clients POST without application/json. The body is parsed as JSON-RPC regardless, and parse failures come back as JSON-RPC errors rather than HTTP 415. Responses are application/json.
Notifications (JSON-RPC messages with no id) get 202 Accepted with no body.
Methods
Method | Purpose |
|---|---|
initialize | Legacy handshake. Returns protocolVersion, capabilities, serverInfo, optional instructions. |
server/discover | 2026-07-28 discovery. Returns supportedVersions, capabilities, identity, optional instructions. |
ping | Health check. Returns {}. |
tools/list | List the available tools (see below). |
tools/call | Invoke a tool. |
tools/list and server/discover carry cache hints (ttlMs, cacheScope: "private") - the tool set is auth- and agent-specific, so cache it briefly and per-credential.
Server instructions. If the org's admin has configured an MCP Instructions hint, its text is returned in the instructions field of initialize / server/discover. Treat it as system guidance for how to use this particular org's tools; it's omitted when unset.
The tools
Five tools are exposed. Search, List, Detail, and Me are read-only data-access tools. AskAgent delegates a whole task to a ChartHop agent - and is the only path to mutations over MCP.
Each tool in tools/list carries MCP annotations: readOnlyHint, destructiveHint, idempotentHint, openWorldHint.
Search
Find entities by name.
Param | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Name to match against. |
entityTypes | string[] | | Which types to search; omit to search all. Options: persons, jobs, fields, contents, functions, appUsers, scenarios, compBands, compReviews, reports, users, orgs, customers. |
includeFormer | boolean | | Include former employees as if current. Default false. |
Use Search to turn a name into an id, then feed that id to Detail or a List filter.
List
List entities of a type as tabular data, with filtering, pagination, sorting, and grouping/aggregation.
Param | Type | Required | Description |
|---|---|---|---|
entityType | enum | Yes | The entity type to list (see Entity types below). |
filter | string | | CQL filter expression, e.g. dept:engineering or status:PENDING. |
columns | string[] | | Columns to return. Omit for the type's default columns. |
sort | string | | Column to sort by; prefix - for descending (e.g. -baseComp). |
limit | integer | | Max results. Default 100, max 200. |
next | string | | Pagination cursor from a prior List result. |
groupBy | string | | Column to group by. When set, next/limit/sort are ignored. |
aggFn | string | | Comma-separated aggregations for groupBy. count is always included; add sum, mean, min, max. |
startDate / endDate | string | | Inclusive range for date-aware types. yyyy-MM-dd or ISO-8601; supports relative dates (today, -30d, startOfMonth). |
scenarioId | string | | List within a planning scenario instead of the live org. |
Pagination: call again with next set to the cursor from the previous result until it's absent.
Detail
Fetch full structured detail for up to 20 entities by id.
Param | Type | Required | Description |
|---|---|---|---|
entityType | enum | Yes | The entity type (see Entity types below). |
ids | string[] | Yes | Entity ids (24-char hex ObjectIds). Max 20. |
startDate / endDate | string | | Range for date-aware entities, yyyy-MM-dd. |
interval | enum | | For date-aware entities: DAY, WEEK, MONTH, QUARTER, FISCAL_QUARTER, YEAR, FISCAL_YEAR. |
scenarioId | string | | View the entity within a scenario. |
Note: ids passed to Detail must come from a Search or List result in the same scope (org, scenario, date range). Pull the id from a List/Search that used the same scenarioId/date window you're about to query.
Me
Returns the identity and profile of the currently authenticated user: their person record, job, role, and org. No parameters required. Useful for grounding a session - call it at the start of an agent loop to establish who the user is before making requests on their behalf.
AskAgent
Delegate a question or task to a ChartHop AI agent. The agent runs autonomously with its own tools and permissions, then returns a result. Use this when you'd rather hand off an org-data question than orchestrate List/Detail yourself. It's also the only path to mutations over MCP.
Param | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | The question or task for the agent. |
agent | enum | | Which agent to ask. Defaults to the org's default agent. |
readOnly | boolean | | If true (default), the agent is restricted to read-only tools. Set false to allow data-modifying tools - subject to the agent's own permissions and the install's write setting. |
complexity | enum | | Reasoning effort: high, medium, low. Defaults to the agent's configured tier. |
Write access via AskAgent. Setting readOnly: false is necessary but not sufficient for a write to succeed. The agent install must also have Allow write access enabled, and the action must be permitted by both the agent's role and the authenticated user's role. Writes execute without a confirmation prompt on the ChartHop side. For the full checklist, see Permissions and Write Access.
Calling a tool
tools/call takes the tool name and an arguments object:
{
"jsonrpc": "2.0",
"id": 42,
"method": "tools/call",
"params": {
"name": "List",
"arguments": {
"entityType": "PERSON",
"filter": "dept:engineering",
"columns": ["name", "title", "manager", "startDate"],
"sort": "-startDate",
"limit": 50
}
}
}The result is standard MCP tool content - a content array of text blocks, with isError set when the call failed:
{
"jsonrpc": "2.0",
"id": 42,
"result": {
"content": [{ "type": "text", "text": "<display-formatted table>" }],
"isError": false
}
}Tool output is display-formatted server-side. A failed call returns isError: true with an explanatory message rather than a JSON-RPC transport error.
Entity types
List and Detail accept these entityType values (the set is filtered to what your access and the org's configuration allow):
PERSON, JOB, GROUP, FIELD, REPORT, REPORT_CHART, EVENT, FILE, FORM, TASK, TEMPLATE, CONTENT, SCENARIO, TABLE, PROCESS, ACTION, CALENDAR, CALENDAR_ENTRY, COMP_BAND, COMP_REVIEW, ASSESSMENT, GOAL, GOAL_TARGET, GOAL_PROGRESS, GOAL_TYPE, STOCK_GRANT, TIMEOFF, TRANSCRIPT.
Custom tables can also be queried by name (use the table's name as the entityType, and TABLE to discover table metadata).
Security model
Understanding this will save debugging time when a call returns less than expected.
- Read-only by default. Search/List/Detail/Me cannot mutate anything.
- Writes require three settings and correct roles. A mutation can only happen through AskAgent with readOnly: false, and only if: AI Chat Write Actions is on (Admin > AI), Enable MCP connections is on, and Allow write access is on (both in Admin > Agents). Even then, the action must be permitted by both the agent's role and the user's own role. See Permissions and Write Access.
- MCP must be enabled on the install for the server to respond at all.
- Everything runs as the agent, on behalf of the authenticated user. Data visibility is the intersection of the agent's role/policies and the user's access. Two different tokens against the same org can legitimately see different results.
- The AI can never exceed the authenticated user's own access. Writes and reads are bounded by what the user can do in the ChartHop UI.
- Scenario/date scope is explicit. If you don't pass scenarioId or a date range, you get the live org as of today.
A minimal agent loop
- Connect and authenticate. Obtain a bearer token for {agent} and org.
- initialize (or server/discover for stateless). Read instructions.
- tools/list. Register Search, List, Detail, Me, AskAgent with your model.
- Call Me to establish the authenticated user's identity.
- Let the model call tools:
- Resolve names to ids with Search.
- Pull tabular/aggregate data with List (paginate via next).
- Expand specific records with Detail (up to 20 ids, matching scope).
- Hand off open-ended tasks - or any write - to AskAgent.
- Feed each tool result's content text back to the model and continue.
