Model Context Protocol server for Forest Admin with OAuth authentication
npm install @forestadmin/mcp-serverModel Context Protocol (MCP) server for Forest Admin with OAuth authentication support.
This MCP server provides HTTP REST API access to Forest Admin operations, enabling AI assistants and other MCP clients to interact with your Forest Admin data through a standardized protocol.
The MCP server is included with the Forest Admin agent. Simply call mountAiMcpServer():
``typescript
import { createAgent } from '@forestadmin/agent';
const agent = createAgent(options)
.addDataSource(myDataSource)
.mountAiMcpServer();
agent.mountOnExpress(app);
agent.start();
`
The MCP server will be automatically initialized and mounted on your application.
You can also run the MCP server standalone using the CLI:
`bash`
npx forest-mcp-server
Or programmatically:
`bash`
node dist/index.js
#### Environment Variables
The following environment variables are required to run the server as a standalone:
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| FOREST_ENV_SECRET | Yes | - | Your Forest Admin environment secret |FOREST_AUTH_SECRET
| | Yes | - | Your Forest Admin authentication secret (must match your agent) |MCP_SERVER_PORT
| | No | 3931 | Port for the HTTP server |
#### Example Configuration
`bash
export FOREST_ENV_SECRET="your-env-secret"
export FOREST_AUTH_SECRET="your-auth-secret"
export MCP_SERVER_PORT=3931
npx forest-mcp-server
`
Once running, the MCP server exposes a single endpoint:
- POST /mcp - Main MCP protocol endpoint
The server expects MCP protocol messages in the request body and returns MCP-formatted responses.
- HTTP Transport: Uses streamable HTTP transport for MCP communication
- OAuth Authentication: Built-in support for Forest Admin OAuth
- CORS Enabled: Allows cross-origin requests
- Express-based: Built on top of Express.js for reliability and extensibility
`bash`
npm run build
`bash`
npm run build:watch
`bash`
npm run lint
`bash`
npm test
`bash``
npm run clean
The server consists of:
- ForestMCPServer: Main server class managing the MCP server lifecycle
- McpServer: Core MCP protocol implementation
- StreamableHTTPServerTransport: HTTP transport layer for MCP
- Express App: HTTP server handling incoming requests
GPL-3.0
https://github.com/ForestAdmin/agent-nodejs
For issues and feature requests, please visit the GitHub repository.