AG

AgentBay MCP Server for Serverless AI Agents

Deploy scalable serverless AI agents with AgentBay's MCP server for reliable cloud infrastructure, fast setup, and secure orchestration.

Overview

AgentBay MCP Server implements a Model Context Protocol (MCP) server intended to make it simple to run serverless AI agents that orchestrate models, tools, and data in cloud environments. It separates agent orchestration and tool execution from the underlying model providers so you can swap LLM backends, scale horizontally, and keep agent logic stateless in a serverless architecture.

By exposing a compact HTTP/JSON protocol for sessions, contexts, tool registration, and agent actions, the MCP server helps teams standardize how agents are created, persisted, and invoked. This reduces boilerplate when integrating models with external tools (databases, search, web fetchers, code runners) and makes deployment to platforms like Cloud Run, AWS Lambda, or Vercel straightforward.

Features

  • Protocol-first server for agent contexts, sessions, and actions (Model Context Protocol)
  • Adapter model: pluggable LLM providers and tool plugins
  • Stateless design suited for serverless deployment and autoscaling
  • Session and context persistence with configurable backends (Redis, Postgres, S3-compatible storage)
  • Authentication / API key support for secure orchestration
  • Webhook and event hooks for external integrations
  • Lightweight REST API suitable for CI/CD automation and microservice architectures

Installation / Configuration

Below are typical steps to get the MCP server running locally and examples for containerized deployment. Adjust environment variables to match your chosen provider and storage backend.

Clone the repository:

git clone https://github.com/Michael98671/agentbay.git
cd agentbay

Run with Docker (recommended for consistency):

# docker-compose.yml
version: "3.8"
services:
  mcp:
    build: .
    image: agentbay/mcp:latest
    ports:
      - "8080:8080"
    environment:
      - MCP_PORT=8080
      - PROVIDER=openai
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - STORAGE_URL=redis://redis:6379/0
  redis:
    image: redis:6-alpine

Start:

docker-compose up --build

Environment variables (example .env):

MCP_PORT=8080
PROVIDER=openai              # or "azure", "local" depending on adapters available
OPENAI_API_KEY=sk-...
STORAGE_URL=redis://localhost:6379/0
JWT_SECRET=your-secret-key
LOG_LEVEL=info

Serverless deploy (Conceptual): build a container image and push to a cloud registry (ECR/GCR), then create a Cloud Run / Fargate service. Because the MCP server is stateless, scale settings and concurrency can be tuned to match expected agent workloads.

API Quick Examples

Create an agent (POST /v1/agents):

curl -X POST http://localhost:8080/v1/agents \
  -H "Authorization: Bearer ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "support-agent",
    "description": "Customer support assistant",
    "config": {
      "model": "gpt-4",
      "max_tokens": 1024
    }
  }'

Start a session and invoke an action (POST /v1/sessions, POST /v1/sessions/:id/act):

# create session
curl -X POST http://localhost:8080/v1/sessions \
  -H "Authorization: Bearer ${API_KEY}" \
  -d '{"agent_id":"support-agent","user_id":"user-123"}'

# invoke action
curl -X POST http://localhost:8080/v1/sessions/<session_id>/act \
  -H "Authorization: Bearer ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"input":"Help me reset my password","tools":["kb_search","ticket_creator"]}'

Available Resources

The server typically exposes or integrates with these resource types:

ResourcePurpose
AgentDeclarative config for an AI agent (model, policies, toolset)
SessionShort-lived interaction state for a user or task
ToolExternal capability (SQL runner, web fetcher, ticket system)
AdapterConnector to an LLM provider or storage backend
Hook/WebhookOutbound event notification for external systems

Common adapters and plugins to expect:

  • LLM adapters: OpenAI, Azure OpenAI, local LLM runtimes (where supported)
  • Storage: Redis, Postgres, S3-compatible object stores
  • Tool plugins: HTTP fetch, SQL executor, file I/O, custom Function/Action endpoints

Refer to the repository for the exact list of adapters and plugins that ship with the project: https://github.com/Michael98671/agentbay

Use Cases

  1. Customer Support AI

    • Deploy an agent that uses a knowledge-base search tool and ticket-creation tool.
    • Flow: user message → session created → KB search tool runs → model composes reply and optionally opens a ticket via ticket_creator tool.
  2. Data Analysis Assistant

    • Configure a tool plug-in that runs SQL against a data warehouse.
    • Analysts can ask natural-language questions; the agent invokes the SQL tool, retrieves results, and summarizes them.
  3. CI/CD Automation Agent

    • Use an agent to parse build logs, triage failures, and create GitHub issues automatically through a tool adapter.
  4. Scheduled Monitoring Agent (serverless)

    • A cron-triggered serverless function invokes an agent session