Agent templates

Beta

Agents are in the beta phase of development and may not be available on your enrollment. Functionality may change during active development.

When you create an agent, your code repository is generated from an agent template. The template ships with simplified configuration for Ontology MCP (OMCP), Palantir MCP, and the Ontology SDK (OSDK), with common setup moved into the agent library. The template keeps your repository focused on agent logic rather than platform plumbing.

Supported templates

Templates are available for the following agent frameworks:

  • Claude Agent SDK: A TypeScript template built on the Claude Agent SDK ↗, for agents that use Claude models. The agent loop is driven by the query function, and tools are exposed through MCP servers.
  • OpenAI Agents SDK: A TypeScript template built on the OpenAI Agents SDK ↗, for agents that use OpenAI models. The agent loop is driven by the Agent and run primitives.
  • Google ADK: A TypeScript template built on the Google Agent Development Kit (ADK) ↗, for agents that use Google Gemini models. The agent loop is driven by the Agent and InMemoryRunner primitives. Gemini is routed through the Foundry language model proxy, so no Google API key is required.

These templates share the same project structure, argument schema, default MCP configurations, and publishing flow. They differ in how the agent loop and custom tools are defined. Select a template when you create your agent. Unless noted otherwise, the examples in this section use the Claude Agent SDK template.

Project structure

An agent template code repository has the following structure:

Copied!
1 2 3 4 5 6 7 8 agent/ # Your agent code ├── index.ts # Agent entry point and argument schema ├── systemPrompt.ts # System prompt ├── customTools.ts # Custom tools └── mcps/ └── default.ts # Default MCP configurations provided by Foundry utils/ # Shared platform tooling scripts/ # Build scripts
PathDescription
agent/index.tsThe agent entry point. Defines the AgentArguments schema and the runAgent function that drives the agent loop.
agent/systemPrompt.tsThe system prompt that defines how the model behaves.
agent/customTools.tsCustom tools the agent can call, exposed through an in-process MCP server.
agent/mcps/default.tsDefault MCP configurations provided by the template, including Palantir MCP and Ontology MCP.
utils/Shared platform tooling used by the template, including OSDK client helpers and publishing commands.
scripts/Build scripts used to package the agent for publishing.

Editing agent/mcps/default.ts may cause conflicts during repository upgrades. To add your own MCP configurations, create a new file in agent/mcps/ instead, such as agent/mcps/custom.ts.

The agent/mcps/default.ts file includes a Palantir MCP configuration that provides tools to interact with the platform. To reduce token usage, you can enable tool search for Palantir MCP so that tools are discovered on demand rather than loaded all at once.

Customize your agent

System prompt

Edit agent/systemPrompt.ts to change the instructions that define how the agent behaves.

Agent arguments

Agents can accept arguments that are provided for each run. Define them in the AgentArguments schema in agent/index.ts using defineInputs:

Copied!
1 2 3 4 5 6 import { defineInputs, t } from "@palantir/agent-templates-bundle"; export const AgentArguments = defineInputs({ additionalAgentContext: t.string().optional(), // Add your own arguments here });

Arguments are automatically accepted when the agent is invoked and registered as input types when the agent is published to Foundry.

Custom tools

Edit agent/customTools.ts to define tools the agent can call.

For the Claude Agent SDK template, define tools with tool and expose them through an in-process MCP server created with createSdkMcpServer:

Copied!
1 2 3 4 5 6 7 8 9 10 11 import { createSdkMcpServer, tool } from "@anthropic-ai/claude-agent-sdk"; import { z } from "zod"; tool( "my_tool", "Description of what this tool does", z.object({ param: z.string() }), async (params) => { return mcpSuccessResponse("result"); }, );

For the OpenAI Agents SDK template, define tools with tool from @openai/agents:

Copied!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import { tool } from "@openai/agents"; const myTool = tool({ name: "my_tool", description: "Description of what this tool does", parameters: { type: "object", properties: { param: { type: "string" } }, required: ["param"], }, strict: false, execute: async (input) => { return "result"; }, });

For the Google ADK template, define tools with FunctionTool from @google/adk:

Copied!
1 2 3 4 5 6 7 8 9 10 11 import { FunctionTool } from "@google/adk"; import { z } from "zod"; const myTool = new FunctionTool({ name: "my_tool", description: "Description of what this tool does", parameters: z.object({ param: z.string() }), execute: async (input) => { return "result"; }, });

Agent loop

Modify the runAgent function in agent/index.ts to change the prompt, model, MCP servers, or tools passed to the agent.

For the Claude Agent SDK template, retrieve the Ontology MCP configuration, pass it to the query function as an MCP server, and consume the agent's response stream:

Copied!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import { query } from "@anthropic-ai/claude-agent-sdk"; import { getOntologyMcpConfiguration } from "./mcps/default"; export async function runAgent(args: AgentArgs) { const omcpConfig = await getOntologyMcpConfiguration(); const iter = query({ prompt: "...", options: { mcpServers: { ["ontology_mcp"]: omcpConfig, }, }, }); // Consume the agent's response stream }

For the OpenAI Agents SDK template, construct an Agent, connect its MCP servers, run the agent, and consume the result stream:

Copied!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 import { Agent, run, MCPServer } from "@openai/agents"; export async function runAgent(args: AgentArgs) { const mcpServers: MCPServer[] = [ // Add MCP servers here ]; for (const server of mcpServers) { await server.connect(); } try { const agent = new Agent({ name: "MyAgent", instructions: "...", mcpServers, tools: [myTool], model: "gpt-5.4", }); const result = await run(agent, "...", { stream: true }); // Consume the agent's response stream await result.completed; } finally { for (const server of mcpServers) { await server.close(); } } }

For the Google ADK template, construct an Agent, run it with an InMemoryRunner, and consume the event stream. The template provides a FoundryGemini model wrapper, defined in a template-managed foundryGemini.ts file, that routes Gemini through the Foundry language model proxy, so no Google API key is required:

Copied!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 import { Agent, InMemoryRunner, MCPToolset, stringifyContent } from "@google/adk"; import { FoundryGemini } from "./foundryGemini"; export async function runAgent(args: AgentArgs) { const mcpToolsets: MCPToolset[] = [ // Add MCP toolsets here ]; try { const agent = new Agent({ name: "MyAgent", instruction: "...", tools: [...mcpToolsets], model: new FoundryGemini({ model: "gemini-2.5-flash" }), }); const runner = new InMemoryRunner({ agent }); for await (const event of runner.runEphemeral({ userId: "user", newMessage: { role: "user", parts: [{ text: "..." }] }, })) { if (event.content) { console.log(stringifyContent(event)); } } } finally { for (const toolset of mcpToolsets) { await toolset.close(); } } }

Add OSDK and OMCP to your agent

The template makes both OSDK and Ontology MCP available to your agent without client credentials, through the agent's scoped permissions.

Ontology SDK

To give your agent access to Ontology resources, add an Ontology SDK to the agent. As when creating an SDK in Code Workspaces, select the object types, action types, and query functions to include, then generate the SDK. For step-by-step guidance, review Create a new Ontology SDK.

To read and write Ontology data directly, construct an OSDK client bound to your selected Ontology. The Ontology resource identifier (RID) is exposed by the generated SDK:

Copied!
1 2 3 4 import { getOntologySdkClient } from "@palantir/agent-templates-bundle"; import { $ontologyRid } from "@ontology/sdk"; const client = await getOntologySdkClient($ontologyRid);

For guidance on using the OSDK in your agent, review the Ontology SDK documentation and the TypeScript OSDK reference.

Ontology MCP

When you add an Ontology SDK to your agent, an Ontology MCP is created based on the same SDK resources. The Ontology MCP exposes the object types, action types, and query functions in the SDK as MCP tools that your agent's model can call.

The agent/mcps/default.ts file exposes a getOntologyMcpConfiguration helper that resolves the Ontology MCP connection at runtime and returns an HTTP MCP server configuration. Because the URL and authorization headers are resolved through scoped permissions, no client ID, secret, or Foundry token is required:

Copied!
1 2 3 4 5 6 7 8 export const getOntologyMcpConfiguration: () => Promise<McpHttpServerConfig> = async () => { const { url, headers } = await getOntologyMcpConnection(); return { type: "http", url, headers, }; };

To use Ontology MCP, pass the configuration to your agent's MCP servers as shown in Agent loop. For more information on the tools Ontology MCP exposes, review the Ontology MCP documentation.

Next steps