text
stringlengths
0
59.1k
Custom endpoints are treated as **user** routes by default. Add them to `publicRoutes` if they should be public.
## Example
See the example: [with-auth on GitHub](https://github.com/VoltAgent/voltagent/tree/main/examples/with-auth)
<|endoftext|>
# source: VoltAgent__voltagent/website/recipes/mcp-chatgpt.md type: docs
---
id: mcp-chatgpt
slug: chatgpt-app
title: ChatGPT App With VoltAgent
description: Deploy the VoltAgent-based AI agent, expose it over MCP, and connect it to ChatGPT Apps.
repository: https://github.com/VoltAgent/voltagent/tree/main/examples/with-mcp-server
---
# Building a ChatGPT App With VoltAgent
This guide shows how to use VoltAgent to deploy an MCP server and connect it to ChatGPT Apps using the Apps SDK.
Our starting point is the `with-mcp-server` example, which bundles multiple agents, helper tools, and an expense approval workflow behind a Model Context Protocol surface.
### Setup
#### Create the app
Use the VoltAgent CLI to bootstrap the example locally:
```bash
pnpm create voltagent-app@latest -- --example with-mcp-server
cd with-mcp-server
```
The project comes pre-configured with a VoltAgent runtime, the Hono server provider, and an MCP configuration.
#### Configure the MCP server
Inside `examples/with-mcp-server/src/index.ts`, an MCPServer instance exposes VoltAgent registries to MCP clients:
```typescript
const mcpServer = new MCPServer({
name: "voltagent-example",
version: "0.1.0",
description: "VoltAgent MCP stdio example",
protocols: { stdio: true, http: true, sse: true },
workflows: { expenseApprovalWorkflow },
adapters: {
prompts: {
/* prompt registry */
},
resources: {
/* read-only knowledge assets */
},
elicitation: {
/* human-in-the-loop approvals */
},
},
});
```
The adapters demonstrate how prompts, resources, and elicitation bridges can be surfaced to MCP clients without modifying the global VoltAgent registry.
#### Register the MCP server with VoltAgent
The same file wires agents, workflows, and the MCP server into a single VoltAgent instance:
```typescript
new VoltAgent({
agents: {
supervisorAgent,
translatorAgent,
storyWriter,
assistant,
},
mcpServers: { mcpServer },
server: honoServer({ port: 3141 }),
logger,
});
```
Key agents include:
- `AssistantAgent` with helper tools like `current_time` and `confirm_action`.
- `SupervisorAgent` that delegates to the creative `StoryWriterAgent` or `TranslatorAgent`.
- Tooling that demonstrates elicitation (manual approval) flows for risky operations.
#### Add the expense approval workflow
The example ships with an `Expense Approval Workflow` built via `createWorkflowChain`:
```typescript
const expenseApprovalWorkflow = createWorkflowChain({
id: "expense-approval",
name: "Expense Approval Workflow",
purpose: "Process expense reports with manager approval for high amounts",
input: z.object({
/* request payload */
}),
result: z.object({