A Model Context Protocol (MCP) server implementation for the Fastly API that enables AI assistants to interact with Fastly CDN services.
This package provides an MCP server that allows AI models to interact with the Fastly API through a standardized protocol. It implements the Model Context Protocol specification, enabling AI assistants to execute operations on the Fastly CDN platform like:
- Managing services, versions, domains, and backends
- Configuring cache settings and VCL
- Performing content purging
- Working with edge dictionaries and ACLs
- Accessing stats and metrics
- Managing WAF and rate limiting
- Seamless AI Integration: Allow AI models to interact directly with your Fastly CDN configuration
- Natural Language Control: Enable conversational interfaces for Fastly administration
- Standardized Protocol: Built on MCP for consistent integration with various AI systems
- Enhanced Capabilities: Exposes all essential Fastly operations through a unified interface
Recommendation: Bun is the preferred runtime for fastly-mcp-server due to its superior performance and startup time.
# With Bun (recommended)
bun add -g fastly-mcp-server
# With npm
npm install -g fastly-mcp-server
# With yarn
yarn global add fastly-mcp-server
# With pnpm
pnpm add -g fastly-mcp-server
# With Bun (recommended)
bun add fastly-mcp-server
# With npm
npm install fastly-mcp-server
# With yarn
yarn add fastly-mcp-server
# With pnpm
pnpm add fastly-mcp-server
# Using bunx (recommended, no installation required)
bunx fastly-mcp-server@latest run
# If installed globally with Bun
fastly-mcp-server run
# Using npx (Node.js alternative)
npx fastly-mcp-server@latest run
{
"mcpServers": {
"fastly api": {
"command": "bunx",
"args": ["fastly-mcp-server@latest", "run"],
"env": {
"API_KEY_APIKEYAUTH": "your-fastly-api-key"
}
}
}
}
{
"mcpServers": {
"fastly": {
"command": "npx",
"args": ["-y", "fastly-mcp-server@latest", "run"],
"env": {
"API_KEY_APIKEYAUTH": "your-fastly-api-key"
}
}
}
}
The server requires a Fastly API key to authenticate with the Fastly API. You can provide this in several ways:
export API_KEY_APIKEYAUTH=your-fastly-api-key
Create a .env
file in your project root:
API_KEY_APIKEYAUTH=your-fastly-api-key
As shown in the usage examples above, you can provide the API key in the environment variables section of your AI assistant's configuration.
The server will automatically set the Fastly-Key
header with your API key for all requests to the Fastly API.
To get a Fastly API key for use with the MCP server:
- Log in to your Fastly account at https://manage.fastly.com
- Navigate to "Account" in the top right menu
- Select "Personal API tokens" from the sidebar
- Click the "Create token" button
- Provide a name for your token (e.g., "MCP Server")
- Select the appropriate scope for your needs:
- For read-only access: Select "global:read"
- For full access: Select "global:write"
- Set an expiration date if desired (or leave as "never" for permanent tokens)
- Click "Create" to generate your API token
- Copy the displayed token immediately (it will only be shown once)
- Use this token as the value for
API_KEY_APIKEYAUTH
in your configuration
Important Security Notes:
- Store your API key securely and never commit it to version control
- Consider using environment variables or a secure secrets manager
- Use the most restrictive scope necessary for your application
- Rotate API keys regularly following security best practices
The server provides comprehensive tools for interacting with the Fastly API:
- List all services
- Get service details
- Create new services
- Update existing services
- Delete services
- List versions
- Clone versions
- Activate versions
- Domain management (add, list, delete)
- Origin configuration
- Backend management
- Cache settings
- Purge all content
- Purge by URL
- Purge by surrogate key
- Soft purges
- Check purge status
- WAF configuration and rule management
- Rate limiting setup and configuration
- Edge dictionary management
- Dictionary item operations
- VCL file management
- Service statistics
- Realtime metrics
- Historical stats
Many API endpoints require path parameters such as service_id
or version_id
. When using these tools, you must provide these parameters in your request:
// To get service details
{
"service_id": "3ELXhLGOuQTQvW9NR3wlWD"
}
// To list versions for a service
{
"service_id": "3ELXhLGOuQTQvW9NR3wlWD"
}
// To activate a version
{
"service_id": "3ELXhLGOuQTQvW9NR3wlWD",
"version_id": "2"
}
// To purge a specific URL
{
"url": "www.example.com/path/to/resource"
}
Here are some common workflows you can implement with this MCP server:
- Create a service
- Add domains
- Configure origin server
- Configure backend
- Activate version
- Get service details
- Purge specific URL, surrogate key, or all content
- Get current origins
- Clone active version
- Update origin
- Activate new version
# Clone the repository
git clone https://github.com/jedisct1/fastly-openapi-schema.git
cd fastly-openapi-schema/fastly-mcp-server
# Install dependencies (with Bun, recommended)
bun install
# Or with npm
npm install
# Build the server (with Bun, recommended)
bun run build
# Or with npm
npm run build
# Run type checking (with Bun, recommended)
bun run typecheck
# Or with npm
npm run typecheck
- Fastly OpenAPI Schema - The OpenAPI schema this server is based on
- Model Context Protocol - The protocol specification
MIT