Skip to content

Parth-Bhovad/contentstack-agent-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Agent Server

This is the backend server for the Contentstack Agent SDK. It handles AI queries, fetches Contentstack content types, and streams AI responses to the client.

Features

  • Express.js server with REST APIs

  • Contentstack integration – fetches and caches content types

  • Webhook support – automatically refresh cached schemas on updates

  • AI-powered responses – connects to LLM providers (Google, Groq, etc.)

  • Streaming support – sends partial responses in real-time via chunks

  • MongoDB storage – stores cached Contentstack schemas

Getting Started

  1. Clone the repo
git clone https://github.com/Parth-Bhovad/contentstack-agent-server.git
cd contentstack-agent-server
  1. Install dependencies
npm install
# or
yarn install
  1. Environment variables Create a .env file in the root directory with:
PORT=8080

# Contentstack credentials
CONTENTSTACK_API_KEY=your_stack_api_key
CONTENTSTACK_DELIVERY_TOKEN=your_delivery_token
CONTENTSTACK_ENVIRONMENT=your_environment
#LLM API keys
GOOGLE_API_KEY=your_gemini_api_key
GROQ_API_KEY=your_groq_api_key

# Database
MONGO_URI=your_mongo_uri
  1. Run the server
npm start

The server will be available at:

http://localhost:8080

Note: Before Using APIs use this command and authenticate with contentstack

npx @contentstack/mcp --auth

API Endpoints

GET / testing check endpoint. Response:

{
  "message": "Welcome to the AI Agent Server API"
}

POST /api/v1/ask Ask a question and stream AI response back. Request body:

{
  "query": "What is the latest blog?",
  "contentstackApiKey": "your_stack_api_key",
  "llmApiKey": "your_llm_api_key",
  "llmProvider": "google"
}

Response: (streaming chunks of text, not JSON)

POST /webhook Webhook handler from Contentstack. When a content type changes, this endpoint clears the cached schema in MongoDB so the server always fetches fresh content types. It will happen automatically. You Don't need to worry about this endpoint. It is mentioned for reference purpose.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published