This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
MCP (Model Context Protocol) server for Coolify that provides 38 token-optimized tools for AI assistants to manage infrastructure through natural language. Tools cover servers, projects, environments, applications, databases, services, deployments, private keys, teams, cloud tokens, documentation search, smart diagnostics, and batch operations. v2.0.0 reduced token usage by 85% (from ~43,000 to ~6,600 tokens) by consolidating related operations into single tools with action parameters.
npm install # Install dependencies
npm run build # Build TypeScript to dist/
npm test # Run all tests
npm run lint # Run ESLint
npm run format # Run Prettier
# Run locally
COOLIFY_BASE_URL="https://your-coolify.com" COOLIFY_ACCESS_TOKEN="token" node dist/index.jsWhen adding new Coolify API endpoints, follow this order:
- src/types/coolify.ts - Add TypeScript interfaces
- src/lib/coolify-client.ts - Add API client method with explicit return type
- src/lib/mcp-server.ts - Add MCP tool definition
- src/tests/mcp-server.test.ts - Add mocked test
- src/index.ts - Entry point, starts MCP server
- src/lib/coolify-client.ts - HTTP client wrapping Coolify REST API
- src/lib/mcp-server.ts - MCP tool definitions and handlers
- src/types/coolify.ts - All Coolify API type definitions
- docs/openapi-chunks/ - OpenAPI spec chunks for reference
List endpoints return summaries (uuid, name, status) not full objects. This reduces response sizes by 90-99%. Use get_* tools for full details of a single resource.
- Verify endpoint exists in
docs/openapi-chunks/ - Add types to
src/types/coolify.ts - Add client method with explicit return type
- Add MCP tool to
src/lib/mcp-server.ts - Add mocked tests (required for codecov coverage)
IMPORTANT: All new client methods MUST have test coverage to pass codecov checks.
When adding new client methods, you must add:
-
Client method tests in
src/__tests__/coolify-client.test.ts:- Test the HTTP method (GET, POST, PATCH, DELETE)
- Test the endpoint path
- Test the request body if applicable
- Follow the existing test patterns in the file
-
Method existence tests in
src/__tests__/mcp-server.test.ts:- Add
expect(typeof client.methodName).toBe('function');in the appropriate section - Ensures the method is properly exported and accessible
- Add
codecov will fail PRs with uncovered lines. Always run npm test before committing.
async getResource(uuid: string): Promise<Resource> {
return this.request<Resource>(`/resources/${uuid}`);
}it('should call client method', async () => {
const spy = jest.spyOn(server['client'], 'getResource').mockResolvedValue({ uuid: 'test' });
await server.get_resource('test-uuid');
expect(spy).toHaveBeenCalledWith('test-uuid');
});After fixing bugs, always verify fixes work against the real Coolify instance — not just unit tests.
/smoke-test— Slash command that builds the project and runs integration smoke tests against the live server. Use this after any bug fix to confirm the fix works end-to-end.npm run test:integration— Runs all integration tests (requires.envwithCOOLIFY_URLandCOOLIFY_TOKEN).- Integration test files live in
src/__tests__/integration/and are excluded fromnpm test(CI). Add new smoke tests there when fixing bugs that involve API interaction.
The Coolify OpenAPI docs are unreliable — always test against the real API. Known issues:
docker_compose_rawrequires base64 — The API expects base64-encoded YAML, but the field name suggests raw content. The client auto-encodes this field so models and callers can pass plain YAML.- Validation errors vary in format — The
errorsfield in API error responses can containstring[]or plainstringvalues. The client handles both.
- Always include explicit return types on functions
- No implicit any types
- Follow existing patterns in the codebase
- Commit frequently to trigger pre-commit hooks (linting, formatting, tests)
- Always stage all modified files after making changes
- Push changes to remote after committing
- Work on feature branches, not main
CI auto-publishes to npm via trusted publishing on version bump. Use:
npm version patch|minor|major
git push origin main --tagsWhen making changes to the codebase, ensure documentation is updated:
-
CHANGELOG.md - Add entry under appropriate version with:
### Added- New features### Changed- Breaking changes or significant modifications### Fixed- Bug fixes- Follow Keep a Changelog format
-
README.md - Update if:
- Tool count changes (update tool count in Features section)
- New tools added (add to appropriate category in Available Tools)
- New example prompts needed
- Response size improvements made (update comparison table)
-
This file (CLAUDE.md) - Update tool count if changed (currently 38 tools)
Always work on a feature branch and include documentation updates in the same PR as code changes.