Forest Admin - API reference
    Preparing search index...

    Module @forestadmin/mcp-server

    @forestadmin/mcp-server

    Model 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():

    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:

    npx forest-mcp-server
    

    Or programmatically:

    node dist/index.js
    

    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
    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
    npm run build
    
    npm run build:watch
    
    npm run lint
    
    npm test
    
    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.

    Classes

    ForestMCPServer
    ForestServerClientImpl

    Interfaces

    ActivityLogsServiceInterface
    CreateForestServerClientOptions
    ForestMCPServerOptions
    ForestServerClient
    SchemaServiceInterface

    Type Aliases

    HttpCallback

    Variables

    MCP_PATHS

    Functions

    createForestServerClient
    isMcpRoute