A production-ready, enterprise-grade Model Context Protocol (MCP) server that exposes the Backstage Catalog API as tools for Large Language Models (LLMs). Features comprehensive operational transparency, cross-platform compatibility, and automated error recovery.
This allows LLMs to interact with Backstage software catalogs through a standardized protocol with enterprise-grade reliability and monitoring.
- Complete Catalog API Coverage: Implements all major Backstage Catalog API endpoints as MCP tools
- Dynamic Tool Loading: Automatically discovers and registers tools from the codebase
- Type-Safe: Full TypeScript support with Zod schema validation
- Production Ready: Built for reliability with proper error handling and logging
- Enterprise Grade: Cross-platform support with operational transparency and monitoring
- Operational Transparency: Comprehensive audit trails, health monitoring, and automated error recovery
- Cross-Platform Compatibility: Works seamlessly on Windows, macOS, and Linux
- Advanced Build System: Dual-format builds (ESM/CommonJS) with minification and tree-shaking
get_entity_by_ref- Get a single entity by referenceget_entities- Query entities with filtersget_entities_by_query- Advanced entity querying with orderingget_entities_by_refs- Get multiple entities by referencesget_entity_ancestors- Get entity ancestry treeget_entity_facets- Get entity facet statistics
get_location_by_ref- Get location by referenceget_location_by_entity- Get location associated with an entityadd_location- Create a new locationremove_location_by_id- Delete a location
refresh_entity- Trigger entity refreshremove_entity_by_uid- Delete entity by UIDvalidate_entity- Validate entity structure
- Node.js 18+
- Yarn 4.4.0+ (configured as packageManager)
- Access to a Backstage instance
- Cross-platform support: Windows (with MSYS/Cygwin), macOS, or Linux
-
Clone the repository:
git clone https://github.com/Coderrob/backstage-mcp-server.git cd backstage-mcp-server -
Install dependencies:
yarn install
-
Build and validate the project:
yarn build:validate
Or build manually:
yarn build
-
(Optional) Run dependency analysis:
yarn deps:analyze
The server requires environment variables for Backstage API access:
BACKSTAGE_BASE_URL- Base URL of your Backstage instance (e.g.,https://backstage.example.com)
Choose one of the following authentication methods:
BACKSTAGE_TOKEN- Bearer token for API accessBACKSTAGE_CLIENT_ID,BACKSTAGE_CLIENT_SECRET,BACKSTAGE_TOKEN_URL- OAuth credentialsBACKSTAGE_API_KEY- API key authenticationBACKSTAGE_SERVICE_ACCOUNT_KEY- Service account key
export BACKSTAGE_BASE_URL=https://backstage.example.com
export BACKSTAGE_TOKEN=your-auth-token-hereyarn startThe server will start and listen for MCP protocol messages on stdin/stdout.
This server is designed to work with MCP-compatible clients. Configure your MCP client to use this server:
{
"mcpServers": {
"backstage": {
"command": "node",
"args": ["dist/index.js"],
"env": {
"BACKSTAGE_BASE_URL": "https://your-backstage-instance.com",
"BACKSTAGE_TOKEN": "your-backstage-token"
}
}
}
}For global installation after NPM publishing:
{
"mcpServers": {
"backstage": {
"command": "backstage-mcp-server",
"env": {
"BACKSTAGE_BASE_URL": "https://your-backstage-instance.com",
"BACKSTAGE_TOKEN": "your-backstage-token"
}
}
}
}Once connected, LLMs can use natural language to interact with Backstage:
User: "Show me all the services in the catalog"
LLM: Uses get_entities tool with appropriate filters
User: "What's the location for the user-service entity?"
LLM: Uses get_location_by_entity tool
All tools accept parameters as defined by their Zod schemas. Entity references can be provided as:
- String:
"component:default/user-service" - Object:
{ kind: "component", namespace: "default", name: "user-service" }
All tools return JSON responses with the following structure:
{
"status": "success" | "error",
"data": <result>
}src/
├── api/ # Backstage API client
├── auth/ # Authentication and security
├── cache/ # Caching layer
├── decorators/ # Tool decorators
├── tools/ # MCP tool implementations
├── types/ # Type definitions and constants
├── utils/ # Utility functions
└── index.ts # Main server entry point
scripts/
├── validate-build.sh # Build validation with operational transparency
├── dependency-manager.sh # Dependency analysis with cross-platform support
├── deps-crossplatform.sh # Cross-platform dependency operations
├── monitor.sh # System monitoring and health checks
└── deps.sh # Legacy dependency scripts
docs/
├── OPERATIONAL_TRANSPARENCY.md # Operational transparency documentation
├── DEPENDENCY_GUIDE.md # Dependency management guide
├── EDGE_CASES_SUMMARY.md # Edge cases and cross-platform considerations
└── BUILD_SETUP.md # Build system documentation
yarn buildThe build system uses Rollup to create optimized bundles for both CommonJS and ESM formats:
dist/index.cjs- CommonJS bundle with shebang for CLI usagedist/index.mjs- ESM bundledist/index.d.ts- TypeScript declarations
- Dual Format Support: Generates both CommonJS and ESM outputs for maximum compatibility
- Minification: All outputs are minified for production use with Terser
- Source Maps: Includes source maps for debugging
- TypeScript Declarations: Bundled .d.ts files for type safety
- Global Installation: The CommonJS build includes a shebang for global npm installation
- Tree Shaking: Removes unused code for smaller bundle sizes
- Cross-Platform Builds: Consistent builds across Windows, macOS, and Linux
- Build Validation: Automated validation with operational transparency
- Error Recovery: Automatic rollback on build failures
The package is configured for publishing to NPM with:
npm publishAfter publishing, the server can be installed globally:
npm install -g @coderrob/backstage-mcp-server
backstage-mcp-serverThis MCP server includes comprehensive operational transparency and enterprise-grade features:
- Real-time Health Monitoring: Continuous system health tracking
- Resource Usage Tracking: Memory, disk, and CPU monitoring
- SLA Tracking: Service Level Agreement monitoring and reporting
- Automated Alerts: Configurable alerting for critical conditions
- Cross-Platform Compatibility: Consistent operation across Windows, macOS, and Linux
- Dependency Analysis: Comprehensive dependency conflict detection and resolution
- Build Validation: Automated build verification with rollback capabilities
- Audit Trails: Complete audit logging for all operations
- Network Resilience: Automatic retry logic for network operations
- Build Rollback: Automatic rollback on build failures
- Dependency Backup/Restore: Backup and restore capabilities for dependencies
- Structured Logging: JSON-formatted logs with full context
# Check system health
yarn monitor:health
# View monitoring dashboard
yarn monitor:dashboard
# Check alerts
yarn monitor:alerts# Analyze dependencies
yarn deps:analyze
# Validate dependency health
yarn deps:validate
# Cross-platform dependency operations
yarn deps:crossplatform# Comprehensive build validation
yarn build:validate
# Development build
yarn build:dev
# Watch mode
yarn build:watchyarn testyarn lint- Create a new tool file in
src/tools/ - Implement the tool class with
@Tooldecorator - Export from
src/tools/index.ts - Define Zod schema for parameters
Example:
@Tool({
name: 'my_tool',
description: 'Description of my tool',
paramsSchema: z.object({ param: z.string() }),
})
export class MyTool {
static async execute({ param }, context) {
// Implementation
return JsonToTextResponse({ status: 'success', data: result });
}
}We welcome contributions! Please see our contribution guidelines and ensure all changes include appropriate tests.
- Fork the repository
- Create a feature branch
- Make your changes with comprehensive testing
- Run the full validation suite:
yarn build:validate && yarn deps:analyze - Submit a pull request
This project is licensed under the GPLv3 License - see the LICENSE file for details.
- Operational Transparency Guide
- Dependency Management Guide
- Build System Documentation
- Edge Cases & Cross-Platform
- Backstage - The platform this server integrates with
- Model Context Protocol - The protocol specification
- Backstage Catalog Client - Official Backstage client library
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
const client = new Client(
{
name: 'example-client',
version: '1.0.0',
},
{
capabilities: {},
}
);
// Connect to the Backstage MCP server
await client.connect(new StdioServerTransport(process));
// List available tools
const tools = await client.request({ method: 'tools/list' });
console.log('Available tools:', tools);
// Call a tool
const result = await client.request({
method: 'tools/call',
params: {
name: 'get_entity_by_ref',
arguments: {
entityRef: 'component:default/my-component',
},
},
});
console.log('Tool result:', result);