Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4a8902e
Improve README: feature VS Code one-click install prominently
ChrisEdwards Oct 7, 2025
a40d9e9
Format security warning as GitHub callout block
ChrisEdwards Oct 7, 2025
8612e35
Use input variables for VS Code install credentials
ChrisEdwards Oct 7, 2025
9424b04
Merge branch 'main' into AIML-83-cleanup-readme
ChrisEdwards Nov 7, 2025
60017ed
Restructure documentation with separate installation guides
ChrisEdwards Nov 7, 2025
9ff6ced
Simplify README: Docker-first, IntelliJ + VS Code focus
ChrisEdwards Nov 8, 2025
fc751bc
Improve README Quick Start flow and add installation guides
ChrisEdwards Nov 10, 2025
9e0a93d
Improve installation guide clarity and consistency
ChrisEdwards Nov 10, 2025
07c1009
Add Jira integration guidelines to AGENTS.md
ChrisEdwards Nov 11, 2025
89e4dbe
Improve README: consolidate JAR section and simplify proxy docs
ChrisEdwards Nov 11, 2025
e7d8de3
Make proxy configuration examples host-agnostic
ChrisEdwards Nov 11, 2025
139e5fe
Improve proxy documentation readability and structure
ChrisEdwards Nov 11, 2025
ab563c8
Clarify proxy configuration: choose ONE approach, not both
ChrisEdwards Nov 11, 2025
276f91a
Simplify installation guides index for faster navigation
ChrisEdwards Nov 11, 2025
c3baaf1
Make installation guide links consistent
ChrisEdwards Nov 11, 2025
42fd9d4
Clarify MCP host compatibility and improve section naming
ChrisEdwards Nov 11, 2025
267356a
Add official VS Code MCP servers documentation reference
ChrisEdwards Nov 11, 2025
fd7b306
Standardize MCP server name to 'contrast' across all configs
ChrisEdwards Nov 11, 2025
0fec727
Update VS Code install button text to 'contrast-mcp'
ChrisEdwards Nov 11, 2025
1e5c95c
Add link to Workspace vs User Settings section in VS Code guide
ChrisEdwards Nov 11, 2025
11a62b0
Add official Claude Desktop MCP documentation reference
ChrisEdwards Nov 11, 2025
8d1611d
Add official Cline MCP documentation reference
ChrisEdwards Nov 11, 2025
c71f926
Remove Next Steps and Related Documentation from installation guides
ChrisEdwards Nov 11, 2025
8d91caf
Fix typos and improve grammar in documentation
ChrisEdwards Nov 11, 2025
d13825d
Update install-claude-code.md
ChrisEdwards Nov 13, 2025
05b2520
Update install-claude-desktop.md
ChrisEdwards Nov 13, 2025
1881c83
Update install-cline.md
ChrisEdwards Nov 13, 2025
8c25219
Update install-intellij.md
ChrisEdwards Nov 13, 2025
0b50460
Update install-oterm.md
ChrisEdwards Nov 13, 2025
1fb8f2e
Update install-vscode.md
ChrisEdwards Nov 13, 2025
0a47cdb
Merge branch 'main' into AIML-83-cleanup-readme
ChrisEdwards Nov 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# AI Agent Guidelines

## Issue Tracking with bd (beads)

**IMPORTANT**: This project uses **bd (beads)** for ALL issue tracking. Do NOT use markdown TODOs, task lists, or other tracking methods.

### Why bd?

- Dependency-aware: Track blockers and relationships between issues
- Git-friendly: Auto-syncs to JSONL for version control
- Agent-optimized: JSON output, ready work detection, discovered-from links
- Prevents duplicate tracking systems and confusion

### Quick Start

**Check for ready work:**
```bash
bd ready --json
```

**Create new issues:**
```bash
bd create "Issue title" -t bug|feature|task -p 0-4 --json
bd create "Issue title" -p 1 --deps discovered-from:bd-123 --json
```

**Claim and update:**
```bash
bd update bd-42 --status in_progress --json
bd update bd-42 --priority 1 --json
```

**Complete work:**
```bash
bd close bd-42 --reason "Completed" --json
```

### Issue Types

- `bug` - Something broken
- `feature` - New functionality
- `task` - Work item (tests, docs, refactoring)
- `epic` - Large feature with subtasks
- `chore` - Maintenance (dependencies, tooling)

### Priorities

- `0` - Critical (security, data loss, broken builds)
- `1` - High (major features, important bugs)
- `2` - Medium (default, nice-to-have)
- `3` - Low (polish, optimization)
- `4` - Backlog (future ideas)

### Workflow for AI Agents

1. **Check ready work**: `bd ready` shows unblocked issues
2. **Claim your task**: `bd update <id> --status in_progress`
3. **Work on it**: Implement, test, document
4. **Discover new work?** Create linked issue:
- `bd create "Found bug" -p 1 --deps discovered-from:<parent-id>`
5. **Complete**: `bd close <id> --reason "Done"`
6. **Commit together**: Always commit the `.beads/issues.jsonl` file together with the code changes so issue state stays in sync with code state

### Jira Integration

When creating beads that relate to Jira tickets:
- **Always prepend the Jira issue ID to the bead title**
- Example: `"AIML-224: Consolidate RouteCoverageService tools"`
- NOT: `"Consolidate RouteCoverageService tools"`
- **Set the `external_ref` parameter to the Jira issue ID**
- Use `--external-ref AIML-224` in CLI or `external_ref="AIML-224"` in MCP calls
- This creates bidirectional linkage:
- Bead tracks local technical work (code, tests, implementation)
- Jira tracks project management (planning, stakeholders, timeline)
- Clear connection between both via issue ID in title and external_ref field

### Auto-Sync

bd automatically syncs with git:
- Exports to `.beads/issues.jsonl` after changes (5s debounce)
- Imports from JSONL when newer (e.g., after `git pull`)
- No manual export/import needed!

### MCP Server (Recommended)

If using Claude or MCP-compatible clients, install the beads MCP server:

```bash
pip install beads-mcp
```

Add to MCP config (e.g., `~/.config/claude/config.json`):
```json
{
"beads": {
"command": "beads-mcp",
"args": []
}
}
```

Then use `mcp__beads__*` functions instead of CLI commands.

### Managing AI-Generated Planning Documents

AI assistants often create planning and design documents during development:
- PLAN.md, IMPLEMENTATION.md, ARCHITECTURE.md
- DESIGN.md, CODEBASE_SUMMARY.md, INTEGRATION_PLAN.md
- TESTING_GUIDE.md, TECHNICAL_DESIGN.md, and similar files

**Best Practice: Use a dedicated directory for these ephemeral files**

**Recommended approach:**
- Create a `history/` directory in the project root
- Store ALL AI-generated planning/design docs in `history/`
- Keep the repository root clean and focused on permanent project files
- Only access `history/` when explicitly asked to review past planning

**Example .gitignore entry (optional):**
```
# AI planning documents (ephemeral)
history/
```

**Benefits:**
- ✅ Clean repository root
- ✅ Clear separation between ephemeral and permanent documentation
- ✅ Easy to exclude from version control if desired
- ✅ Preserves planning history for archeological research
- ✅ Reduces noise when browsing the project

### Important Rules

- ✅ Use bd for ALL task tracking
- ✅ Always use `--json` flag for programmatic use
- ✅ Link discovered work with `discovered-from` dependencies
- ✅ Check `bd ready` before asking "what should I work on?"
- ✅ Store AI planning docs in `history/` directory
- ❌ Do NOT create markdown TODO lists
- ❌ Do NOT use external issue trackers
- ❌ Do NOT duplicate tracking systems
- ❌ Do NOT clutter repo root with planning documents

For more details, see README.md and QUICKSTART.md.
67 changes: 34 additions & 33 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

**Note**: This project uses [bd (beads)](https://github.com/steveyegge/beads) for issue tracking. Use `bd` commands instead of markdown TODOs. See AGENTS.md for workflow details.

## Project Overview

This is an MCP (Model Context Protocol) server for Contrast Security that enables AI agents to access and analyze vulnerability data from Contrast's security platform. It serves as a bridge between Contrast Security's API and AI tools like Claude, enabling automated vulnerability remediation and security analysis.
Expand All @@ -10,8 +12,10 @@ This is an MCP (Model Context Protocol) server for Contrast Security that enable

### Building the Project
- **Build**: `mvn clean install` or `./mvnw clean install`
- **Package without tests**: `mvn clean package -DskipTests`
- **Test**: `mvn test` or `./mvnw test`
- **Run locally**: `java -jar target/mcp-contrast-0.0.11.jar --CONTRAST_HOST_NAME=<host> --CONTRAST_API_KEY=<key> --CONTRAST_SERVICE_KEY=<key> --CONTRAST_USERNAME=<user> --CONTRAST_ORG_ID=<org>`
- **Run single test**: `mvn test -Dtest=HintGeneratorTest` or `mvn test -Dtest=HintGeneratorTest#specificTestMethod`
- **Run locally**: `java -jar target/mcp-contrast-0.0.12-SNAPSHOT.jar --CONTRAST_HOST_NAME=<host> --CONTRAST_API_KEY=<key> --CONTRAST_SERVICE_KEY=<key> --CONTRAST_USERNAME=<user> --CONTRAST_ORG_ID=<org>`

### Docker Commands
- **Build Docker image**: `docker build -t mcp-contrast .`
Expand All @@ -28,17 +32,19 @@ This is an MCP (Model Context Protocol) server for Contrast Security that enable

**Main Application**: `McpContrastApplication.java` - Spring Boot application that registers MCP tools from all service classes.

**Service Layer**: Each service handles a specific aspect of Contrast Security data:
**Service Layer**: Each service handles a specific aspect of Contrast Security data and exposes `@Tool` annotated methods:
- `AssessService` - Vulnerability analysis and trace data
- `SastService` - Static application security testing data
- `SCAService` - Software composition analysis (library vulnerabilities)
- `ADRService` - Attack detection and response events
- `RouteCoverageService` - Route coverage analysis
- `PromptService` - AI prompt management

**SDK Extensions**: Located in `sdkexstension/` package, these extend the Contrast SDK with enhanced data models and helper methods for better AI integration.
**SDK Extensions**: Located in `sdkexstension/` package:
- `SDKExtension.java` - Extends Contrast SDK API with additional endpoints not in standard SDK (library observations, route details, session metadata, etc.)
- `SDKHelper.java` - Utility methods for hostname protocol handling and common operations
- `data/` subpackages - Enhanced data models with AI-friendly representations organized by domain (application, adr, routecoverage, sca, traces, sessionmetadata)

**Data Models**: Comprehensive POJOs in `data/` package representing vulnerability information, library data, applications, and attack events.
**Data Models**: Comprehensive POJOs in `data/` package representing vulnerability information, library data, applications, and attack events used by service layer.

**Hint System**: `hints/` package provides context-aware security guidance for vulnerability remediation.

Expand All @@ -58,19 +64,24 @@ Required environment variables/arguments:

### Technology Stack

- **Framework**: Spring Boot 3.4.5 with Spring AI 1.0.0-RC1
- **Framework**: Spring Boot 3.4.5 with Spring AI 1.0.1
- **MCP Integration**: Spring AI MCP Server starter
- **Contrast Integration**: Contrast SDK Java 3.4.2
- **Testing**: JUnit 5
- **Build Tool**: Maven with wrapper
- **JSON Processing**: Gson (via Contrast SDK)
- **Testing**: JUnit 5 with Spring Boot Test
- **Build Tool**: Maven 3.6+ with wrapper
- **Packaging**: Executable JAR and Docker container

### Development Patterns

1. **MCP Tools**: Services expose methods via `@Tool` annotation for AI agent consumption
2. **SDK Extension Pattern**: Enhanced data models extend base SDK classes with AI-friendly representations
3. **Hint Generation**: Rule-based system provides contextual security guidance
4. **Defensive Design**: All external API calls include error handling and logging
1. **MCP Tools**: Services expose methods via `@Tool` annotation for AI agent consumption. Register new services in `McpContrastApplication.tools()` bean.
2. **SDK Extension Pattern**:
- Use `SDKExtension` to add new Contrast API endpoints not in the standard SDK
- Use `SDKHelper` for common utility operations (hostname handling, etc.)
- Enhanced data models in `sdkexstension/data/` provide AI-friendly JSON representations
3. **Hint Generation**: Rule-based system in `hints/` package provides contextual security guidance for vulnerability remediation
4. **Defensive Design**: All external API calls include proper resource management (try-with-resources), error handling, and logging
5. **Pagination Handling**: SDK extension methods handle pagination automatically (see `getLibraryObservations` for pattern)

### Security Considerations

Expand All @@ -81,30 +92,20 @@ This codebase handles sensitive vulnerability data. The README contains critical
- Default log location: `/tmp/mcp-contrast.log`
- Debug logging: Add `--logging.level.root=DEBUG` to startup arguments
- Console logging is minimal by design for MCP protocol compatibility
- Debug mode buffers API responses for logging (memory impact with large datasets)

## Beads Workflow Requirements

This project uses Beads (bd) for issue tracking. See the MCP resource `beads://quickstart` for usage details.

### Managing Bead Dependencies

**Command syntax:** `bd dep add <dependent-task> <prerequisite-task>`

Example: If B must be done after A completes, use `bd dep add B A` (not `bd dep add A B`).

Verify with `bd show <task-id>` - dependent tasks show "Depends on", prerequisites show "Blocks".

### Testing Requirements Before Closing Beads
### Troubleshooting

**CRITICAL: Before closing any bead, you MUST:**
For common issues (SSL certificates, proxy configuration, debug logging), see the "Common Issues" and "Proxy Configuration" sections in [README.md](README.md).

1. **Write tests for ALL code changes** - No exceptions
2. **Run unit tests** - `mvn test` must pass with 0 failures
3. **Run integration tests** - `mvn verify` must pass (requires credentials in `.env.integration-test`)
- If credentials unavailable, verify integration tests pass in CI/CD
4. **Verify new tests are included** - Ensure your tests ran and passed
### Adding New MCP Tools

All code changes require corresponding test coverage. Do not close beads without tests.
To add a new tool/service:
1. Create a new `@Service` class with methods annotated with `@Tool(description="...")`
2. Inject dependencies (ContrastSDK, SDKExtension) via constructor
3. Register the service in `McpContrastApplication.tools()` bean method
4. Use `SDKExtension` to add new API endpoints if needed
5. Create enhanced data models in appropriate `sdkexstension/data/` subpackage

See INTEGRATION_TESTS.md for integration test setup and credentials.

Expand All @@ -122,4 +123,4 @@ This project is tracked in Jira under the **AIML** project. When creating Jira t
- `Task` - for simple non-feature changes (refactoring, documentation, bug fixes)
- `Epic` - for large features with many dependent tasks (typically managed by Product Management)

**Access**: Use the Atlassian MCP server to read or write Jira tickets programmatically.
**Access**: Use the Atlassian MCP server to read or write Jira tickets programmatically.
Loading