@forestadmin/mcp-server
v1.5.0
Published
Model Context Protocol server for Forest Admin with OAuth authentication
Downloads
1,654
Readme
@forestadmin/mcp-server
Model Context Protocol (MCP) server for Forest Admin with OAuth authentication support.
Overview
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.
Usage
With Forest Admin Agent
The MCP server is included with the Forest Admin agent. Simply call mountAiMcpServer():
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.
Standalone Server
You can also run the MCP server standalone using the CLI:
npx forest-mcp-serverOr programmatically:
node dist/index.jsEnvironment 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
export FOREST_ENV_SECRET="your-env-secret"
export FOREST_AUTH_SECRET="your-auth-secret"
export MCP_SERVER_PORT=3931
npx forest-mcp-serverAPI Endpoint
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.
Features
- 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
Development
Building
npm run buildWatch Mode
npm run build:watchLinting
npm run lintTesting
npm testCleaning
npm run cleanArchitecture
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
License
GPL-3.0
Repository
https://github.com/ForestAdmin/agent-nodejs
Support
For issues and feature requests, please visit the GitHub repository.
