AB Tasty MCP Server
Official# AB Tasty MCP Server
A Model Context Protocol (MCP) server that integrates AB Tasty's Feature Experimentation & Rollouts platform with AI assistants. This server provides tools for feature flag management, campaign retrieval, and guided SDK integration through the MCP protocol.
## Features
### Tools
- **Decision API Integration**: Retrieve campaigns and feature flags for visitors
- `decision_api_get_campaigns`: Get all campaigns for a visitor with context
- `decision_api_get_campaign`: Get a specific campaign by ID for a visitor
- `decision_api_get_flags`: Get all feature flags for a visitor
- `decision_api_activate_campaign`: Activate a campaign for a visitor
- **Resource Loader API**: Extract and analyze campaign configurations (v0.2.0+)
- `resource_loader_api_load_webexp_resources`: Load Web Experimentation & Personalization resources (use with `we_resource_extractor` prompt)
- `resource_loader_api_load_featexp_resources`: Load Feature Experimentation & Rollout resources (use with `fear_resource_extractor` prompt)
- _Note: In v0.2.0, the Resource Loader API was split into platform-specific tools for better clarity_
### Prompts
- **Quick Start Guides**: Interactive prompts for AB Tasty SDK installation
- Node.js SDK installation guide
- **Resource Extractors**: AI-powered resource configuration generators
- `we_resource_extractor`: Converts natural language campaign briefs into Web Experimentation resource configurations
- `fear_resource_extractor`: Converts natural language campaign briefs into Feature Experimentation resource configurations
- These prompts generate the JSON needed for the Resource Loader API tools
### Resources
- **Documentation**: Access to AB Tasty Feature Experimentation & Rollout documentation directly through MCP
## Prerequisites
- Node.js 18+
- npm or yarn
- AB Tasty credentials:
- Environment ID
- API Key
- (Optional) Account ID and token for Resource Loader features for Web Experimentation
## Installation
1. Clone the repository:
```bash
git clone https://github.com/flagship-io/mcp-server.git
cd mcp-server
```
2. Install dependencies:
```bash
yarn install
```
3. Build the project:
```bash
yarn build
```
## Usage
### Using with npx (Recommended)
The easiest way to use the MCP server is through npx without any installation:
```json
{
"mcpServers": {
"ABTasty": {
"command": "npx",
"args": [
"-y",
"@abtasty/mcp-server",
"--fear-env-id",
"YOUR_FEAR_ENV_ID",
"--fear-api-key",
"YOUR_FEAR_API_KEY",
"--resource-loader-fear-account-id",
"YOUR_FEAR_ACCOUNT_ID",
"--resource-loader-fear-account-environment-id",
"YOUR_FEAR_ACCOUNT_ENVIRONMENT_ID",
"--resource-loader-fear-rca-token",
"YOUR_FEAR_RCA_TOKEN",
"--resource-loader-we-account-id",
"YOUR_WE_ACCOUNT_ID",
"--resource-loader-we-token",
"YOUR_WE_TOKEN"
]
}
}
}
```
Replace the placeholder values with your actual credentials:
- `YOUR_FEAR_ENV_ID`: Your AB Tasty Feature Experimentation account environment ID
- `YOUR_FEAR_API_KEY`: Your AB Tasty Feature Experimentation API key
- `YOUR_FEAR_ACCOUNT_ID`: Your AB Tasty Feature Experimentation Account ID
- `YOUR_FEAR_ACCOUNT_ENVIRONMENT_ID`: Your AB Tasty Feature Experimentation account Environment ID
- `YOUR_FEAR_RCA_TOKEN`: Your AB Tasty Feature Experimentation RCA Token
- `YOUR_WE_ACCOUNT_ID`: Your AB Tasty Web Experimentation Account ID
- `YOUR_WE_TOKEN`: Your AB Tasty Web Experimentation token
**Alternative: Environment Variables**
You can also set credentials via environment variables instead of command-line arguments:
```bash
# Feature Experimentation & Rollout
export FEAR_ENV_ID="your_fear_env_id"
export FEAR_API_KEY="your_fear_api_key"
# Resource Loader - Feature Experimentation & Rollout
export RESOURCE_LOADER_FEAR_ACCOUNT_ID="your_fear_account_id"
export RESOURCE_LOADER_FEAR_ACCOUNT_ENVIRONMENT_ID="your_fear_account_environment_id"
export RESOURCE_LOADER_FEAR_RCA_TOKEN="your_fear_rca_token"
# Resource Loader - Web Experimentation & Personalization
export RESOURCE_LOADER_WE_ACCOUNT_ID="your_we_account_id"
export RESOURCE_LOADER_WE_TOKEN="your_we_token"
```
Then use a simpler npx command:
```json
{
"mcpServers": {
"ABTasty": {
"command": "npx",
"args": ["-y", "@abtasty/mcp-server"]
}
}
}
```
### Running the HTTP Server
Start the server on the default port (3000):
```bash
yarn start
```
Or specify a custom port:
```bash
PORT=8080 yarn start
```
The server will be available at `http://localhost:3000/mcp` (or your custom port).
### Configuration
The server accepts configuration through HTTP headers for each session:
#### Feature Experimentation & Rollout (FEAR) Headers:
- `x-fear-env-id`: Your AB Tasty Feature Experimentation & Rollout environment ID
- `x-fear-api-key`: Your AB Tasty Feature Experimentation & Rollout API key
#### Resource Loader Headers (optional):
**For Web Experimentation & Personalization:**
- `x-resource-loader-we-account-id`: Your AB Tasty Web Experimentation account ID
- `x-resource-loader-we-token`: Your Web Experimentation resource loader authentication token
**For Feature Experimentation & Rollout:**
- `x-resource-loader-fear-account-id`: Your AB Tasty Feature Experimentation & Rollout account ID
- `x-resource-loader-fear-account-environment-id`: Your AB Tasty Feature Experimentation & Rollout environment ID
- `x-resource-loader-fear-rca-token`: Your Feature Experimentation & Rollout (Remote Control API) resource loader authentication token
### Connecting with MCP Clients
The server supports two modes of operation:
#### 1. Stdio Mode (for Claude Desktop and similar clients)
Use the npx command shown above for stdio-based MCP clients like Claude Desktop.
#### 2. HTTP Mode (Streamable HTTP transport)
For HTTP-based clients, the server uses the Streamable HTTP transport protocol. Configure your MCP client to connect to the server endpoint:
```json
{
"mcpServers": {
"ABTasty": {
"url": "http://localhost:3000/mcp",
"headers": {
"x-fear-env-id": "your_env_id",
"x-fear-api-key": "your_api_key"
}
}
}
}
```
### Example: Using Tools
Once connected through an MCP client, you can use the available tools:
**Get campaigns for a visitor:**
```typescript
decision_api_get_campaigns({
visitor_id: "user123",
context: {
age: 25,
country: "US"
},
trigger_hit: true
});
```
**Get feature flags:**
```typescript
decision_api_get_flags({
visitor_id: "user123",
context: {
age: 25,
country: "US"
},
trigger_hit: false
});
```
**Create and load Web Experimentation resources:**
Step 1: Use the `we_resource_extractor` prompt to convert your campaign brief into a resource configuration:
```text
User: Create an A/B test on https://example.com/pricing.
Show a red button for 50% of traffic.
Prompt Output:
{
"needs_clarification": false,
"questions": [],
"resources": [
{
"type": "campaign",
"$_ref": "c1",
"action": "create",
"payload": {...}
}
]
}
```
Step 2: Load the resources using the tool:
```typescript
resource_loader_api_load_webexp_resources({
resourceLoaderContent: {
"needs_clarification": false,
"questions": [],
"resources": [...]
},
dryrun: false,
});
```
**Create and load Feature Experimentation resources:**
Step 1: Use the `fear_resource_extractor` prompt to convert your campaign brief:
```text
User: Create a feature flag 'new-checkout' for 25% of users
Prompt Output:
{
"version": 1,
"needs_clarification": false,
"questions": [],
"resources": [
{
"type": "project",
"$_ref": "p1",
"action": "create",
"payload": {...}
},
{
"type": "campaign",
"$_ref": "c1",
"action": "create",
"payload": {...}
}
]
}
```
Step 2: Load the resources using the tool:
```typescript
resource_loader_api_load_featexp_resources({
resourceLoaderContent: {
"version": 1,
"needs_clarification": false,
"questions": [],
"resources": [...]
},
dryrun: false,
});
```
## Development
### Project Structure
```
├── src/
│ ├── index.ts # Main HTTP server entry point
│ ├── cli.ts # CLI entry point for stdio mode
│ ├── tools/ # MCP tool implementations
│ │ ├── decision-api.ts # Feature flag tools
│ │ └── resource-loader-api.ts
│ ├── prompts/ # Interactive prompt definitions
│ │ ├── quickstart-guide.ts
│ │ └── resource-loader-prompts.ts
│ └── resources/ # Resource providers
│ └── documentation.ts
├── helpers/ # Utility functions
│ ├── abtasty-fear.ts # AB Tasty Feature Experimentation SDK wrapper
│ └── resource-loader.ts # Campaign extraction utilities
├── types/ # TypeScript type definitions
├── assistant-prompts/ # Markdown prompt templates
└── build/ # Compiled output
```
### Development Scripts
```bash
# Generate prompt files
yarn generate:prompts
# Build the project
yarn build
# Build and run
yarn dev
```
### Building from Source
The build process:
1. Generates TypeScript files from markdown prompts
2. Bundles the application with esbuild
3. Copies assistant prompt files to the build directory
```bash
yarn build
```
## Architecture
### Session Management
The server maintains isolated sessions for each client connection:
- Each session has its own credentials (provided via headers)
- Sessions are identified by unique UUIDs
- Sessions are cleaned up when connections close
### Transport Layer
Uses the Streamable HTTP transport from the MCP SDK:
- Supports JSON-RPC 2.0 over HTTP
- Session-based connection management
- Automatic session initialization and cleanup
## Security Notes
- Credentials are session-scoped and not shared between sessions
- Always use HTTPS in production environments
- Store credentials securely and never commit them to version control
## API Documentation
### Tools
#### `decision_api_get_campaigns`
Retrieves all campaigns for a visitor.
**Parameters:**
- `visitor_id` (string): Unique visitor identifier
- `context` (object): Key-value pairs for targeting (optional)
- `trigger_hit` (boolean): Send analytics hit (default: false)
**Returns:** Array of campaigns with variations and modifications
#### `decision_api_get_campaign`
Retrieves a specific campaign by its ID for a visitor.
**Parameters:**
- `visitor_id` (string): Unique visitor identifier
- `campaign_id` (string): Campaign ID to retrieve
- `context` (object): Key-value pairs for targeting (optional)
- `trigger_hit` (boolean): Send analytics hit (default: false)
**Returns:** Campaign with variation and modifications
#### `decision_api_get_flags`
Retrieves all feature flags for a visitor.
**Parameters:**
- `visitor_id` (string): Unique visitor identifier
- `context` (object): Key-value pairs for targeting (optional)
- `trigger_hit` (boolean): Send analytics hit (default: false)
**Returns:** Object with flag keys and their values
#### `decision_api_activate_campaign`
Activates a campaign for a visitor.
**Parameters:**
- `visitor_id` (string): Unique visitor identifier
- `variation_group_id` (string): Variation group ID to activate
- `variation_id` (string): Variation ID to activate
**Returns:** Activation confirmation
#### `resource_loader_api_load_webexp_resources`
Loads Web Experimentation & Personalization resources via the Resource Loader API.
**Workflow:** Use the `we_resource_extractor` prompt to generate the resourceLoaderContent from a natural language campaign brief, then pass it to this tool.
**Parameters:**
- `resourceLoaderContent` (object): JSON containing resource loader content with `needs_clarification`, `questions`, and `resources` array
- `dryrun` (boolean): Whether to simulate the request without sending it
**Returns:** Loaded resources results
#### `resource_loader_api_load_featexp_resources`
Loads Feature Experimentation & Rollout resources via the Resource Loader API.
**Workflow:** Use the `fear_resource_extractor` prompt to generate the resourceLoaderContent from a natural language campaign brief, then pass it to this tool.
**Parameters:**
- `resourceLoaderContent` (object): JSON containing resource loader content with `version`, `needs_clarification`, `questions`, and `resources` array
- `dryrun` (boolean): Whether to simulate the request without sending it
**Returns:** Loaded resources results
## Troubleshooting
### Server won't start
- Check if port 3000 is already in use
- Verify Node.js version (18+ required)
- Ensure dependencies are installed: `yarn install`
### "Invalid credentials" errors
- Verify your environment ID and API key are correct
- Check that headers are properly set in your MCP client configuration
- Ensure credentials have the necessary permissions in AB Tasty
## License
[MIT License](./LICENSE)
## Support
For issues related to:
- **This MCP server**: Open an issue on GitHub
- **AB Tasty platform**: Contact [AB Tasty support](https://support.abtasty.com/)
## Resources
- **MCP protocol**: See [Model Context Protocol documentation](https://modelcontextprotocol.io/)
- **AB Tasty SDK**: See [AB Tasty SDK](https://docs.abtasty.com/server-side/sdks)
TDQS
Scored across 7 tools
The decision API read tools have meaningful overlap: get_campaigns returns campaigns/feature flags with context, while get_flags returns a simplified flag view. get_campaign is distinct by ID, but an agent could easily hesitate between the campaign-list and flag-list tools when looking for flag values.
All tool names use snake_case with module-style prefixes and verb-like operation names, which is mostly predictable. The prefixes are long and slightly uneven in style (decision_api_*, resource_loader_api_*, codebase_analyzer_analyze), but the overall convention is coherent.
Seven tools is a well-scoped set for this server’s apparent purpose: decision/flag retrieval, campaign activation, resource loading, and codebase analysis. Each tool appears to earn its place without excessive surface area.
The surface covers the main read/decision paths, activation, resource loading for both web and feature experimentation, and codebase flag analysis. Minor lifecycle gaps exist, such as broader event/tracking operations or campaign management, but the core MCP workflows appear covered.