- Repository Purpose
- What This Repo Contains
- What This Repo Does NOT Contain
- Repository Structure
- Architecture Principles
- Key Technologies
- AI Assistant Guidelines
- GitHub Copilot Coding Agent Guidelines
- Hard-Learned Lessons
- Common Development Tasks
- GitHub Copilot Development Workflows
- Release Process & Publishing Workflow
- Integration Points
This is the MCP server implementation for the BC Code Intelligence (bc-code-intel) system.
- TypeScript MCP Server: Full Model Context Protocol implementation
- Layer Resolution System: Multi-source knowledge with intelligent override system
- MCP Tools: 20+ tools providing BC knowledge access, specialist discovery, and handoff management
- Service Architecture: Modular services for knowledge, methodologies, code analysis, and specialist management
- Build System: Complete TypeScript build pipeline with testing
- Knowledge Content: Actual BC knowledge is in bc-code-intelligence repo (linked via submodule)
- Markdown Files: No knowledge content directly in this repository
- Domain Expertise: Business logic focuses on layer resolution, not BC domain knowledge
src/
├── layers/ # Layer resolution system
│ ├── layer-service.ts # Core layer management and resolution
│ ├── embedded-layer.ts # Reads from embedded-knowledge/ submodule
│ ├── project-layer.ts # Local ./bc-code-intel-overrides/ detection
│ └── git-layer.ts # Future: Git repository layers
├── services/ # MCP tools and business logic
│ ├── knowledge-service.ts # Knowledge discovery and retrieval
│ ├── methodology-service.ts # Workflow and systematic analysis
│ └── code-analysis-service.ts # BC code pattern analysis
├── types/ # TypeScript interfaces and types
│ ├── bc-knowledge.ts # Knowledge content interfaces
│ ├── layer-types.ts # Layer system types
│ └── mcp-types.ts # MCP protocol extensions
└── index.ts # MCP server entry point
embedded-knowledge/ # Git submodule → bc-code-intelligence
package.json # Dependencies and build scripts
tsconfig.json # TypeScript configuration
- Clean Separation: Server implementation vs knowledge content via submodule
- Layer-Based Resolution: Embedded → Company → Team → Project override system
- Zero-Config Experience: Works immediately with embedded knowledge via submodule
- Extensible Design: Foundation ready for enterprise customization layers
- Version Awareness: BC version compatibility filtering throughout
- Protocol Compliance: Full MCP specification implementation
- Model Context Protocol (MCP): Primary interface for AI tool integration
- TypeScript: Strict typing throughout for reliability
- Git Submodules: Clean knowledge content integration
- Fuse.js: Intelligent knowledge search and discovery
- YAML: Frontmatter parsing for knowledge metadata
- Code Quality: Maintain TypeScript strict mode compliance
- MCP Compatibility: Preserve protocol compatibility in all tool implementations
- Layer Architecture: Respect layer resolution order and override logic
- Backward Compatibility: Ensure existing MCP tools continue functioning
- Performance: Maintain sub-100ms response times for knowledge queries
- Testing: Comprehensive test coverage for all layer resolution scenarios
- NO Knowledge Content: This repo contains no knowledge - it comes from submodule
- Strict Mode: All code must pass TypeScript strict mode compilation
- Interface First: Define interfaces before implementations in
types/ - Error Handling: Use Result pattern for operations that can fail
- Async/Await: Prefer async/await over Promise chains
- Null Safety: Use optional chaining and nullish coalescing
When creating new MCP tools, follow this signature pattern:
export async function toolName(
args: ToolArgs,
context: MCP.ServerContext,
): Promise<MCP.CallToolResult> {
try {
// Validate input
const validatedArgs = validateToolArgs(args);
// Execute business logic
const result = await serviceMethod(validatedArgs);
// Return formatted response
return {
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
};
} catch (error) {
return {
content: [{ type: "text", text: `Error: ${error.message}` }],
isError: true,
};
}
}- Layer Resolution Order: Embedded → Company → Team → Project
- Cache Invalidation: Clear caches when layer configuration changes
- Override Detection: Check local ./bc-code-intel-overrides/ before embedded knowledge
- Version Filtering: Apply BC version compatibility at query time
- Error Propagation: Layer failures should fallback to next layer
// Service interface pattern
interface ServiceInterface {
readonly layerService: LayerService;
initialize(): Promise<void>;
query(criteria: QueryCriteria): Promise<ServiceResult>;
dispose(): void;
}
// Service implementation pattern
export class ConcreteService implements ServiceInterface {
constructor(
public readonly layerService: LayerService,
private readonly config: ServiceConfig,
) {}
}- Unit Tests: 100% coverage for service logic
- Integration Tests: Layer resolution scenarios
- MCP Tests: Tool invocation and response validation
- Performance Tests: Sub-100ms response time validation
- Mock Patterns: Use dependency injection for testability
src/
├── layers/ # Layer system core - handle with extreme care
├── services/ # Business logic - main development area
├── types/ # TypeScript interfaces - define before implementing
├── tools/ # MCP tool definitions - follow signature patterns
└── utils/ # Shared utilities - pure functions only
- Development:
npm run devfor watch mode with hot reload - Type Checking:
npm run type-checkbefore commits - Testing:
npm testwith coverage reporting - Linting:
npm run lintwith auto-fix where possible - Building:
npm run buildfor production distribution
- Updates: Use
git submodule update --remotecarefully - Never Modify: embedded-knowledge/ is read-only from this repo
- Version Sync: Keep submodule in sync with main repo releases
- Testing: Always test after submodule updates
- Response Times: All MCP tools must respond in <100ms
- Memory Usage: Implement proper cleanup in dispose methods
- Caching: Use intelligent caching with proper invalidation
- Batch Operations: Group related queries when possible
- Lazy Loading: Load layers and knowledge on-demand
- ❌ Knowledge in Server: Never add knowledge content to this repo
- ❌ Breaking MCP: Don't change tool signatures without versioning
- ❌ Layer Bypass: Always use LayerService for knowledge access
- ❌ Synchronous Operations: Avoid blocking operations in tools
- ❌ Direct File Access: Use layer system instead of direct file reads
- ❌ Memory Leaks: Always implement proper cleanup and disposal
- ❌ Version Proliferation: Avoid scattering version numbers across documentation
- ❌ File Proliferation: Resist creating redundant/overlapping documentation files
- Version-Agnostic Docs: Keep version numbers ONLY in package.json and CHANGELOG.md
- Single Source of Truth: Avoid duplicating installation/feature info across multiple files
- File Discipline: Regularly audit and remove outdated/redundant documentation
- Evergreen Content: Write documentation that doesn't need version updates
- Agent Oversight: AI agents may create unwanted directories (like vscode-extension/) - regularly audit
- Submodule Clarity: Keep the boundary between MCP server and knowledge content crystal clear
- Cleanup Discipline: Delete temporary files, migration guides, and alpha docs when no longer needed
- Implementing new MCP tools for BC knowledge access
- Extending layer resolution system (git repos, HTTP sources, etc.)
- Adding BC version compatibility filtering
- Enhancing knowledge search and discovery algorithms
- Optimizing layer caching and performance
- Interface Definition: Define tool interface in
types/mcp-types.ts - Tool Implementation: Create tool function in
tools/directory - Service Integration: Connect to appropriate service layer
- Validation Logic: Add input validation and error handling
- Testing Suite: Write unit and integration tests
- Registration: Register tool in main MCP server configuration
- Documentation: Update tool documentation and examples
- Layer Interface: Extend base layer interface if needed
- Implementation: Create new layer service implementation
- Resolution Logic: Update layer resolution order if required
- Caching Strategy: Implement appropriate caching mechanisms
- Testing: Comprehensive layer interaction testing
- Integration: Wire into existing layer service architecture
- Configuration: Add any new configuration options
- Interface Updates: Modify service interfaces first
- Implementation: Update service implementations
- Layer Integration: Ensure proper layer system usage
- Error Handling: Comprehensive error scenarios
- Performance Testing: Validate sub-100ms response times
- Integration Testing: Test with real MCP client scenarios
- Documentation: Update service documentation
- TypeScript First: Always define types before implementation
- Test-Driven: Write tests alongside implementation
- Performance Monitoring: Continuous response time validation
- MCP Compliance: Verify protocol compatibility at each change
- Layer Isolation: Maintain clean separation between layers
Before publishing a new version, complete these steps in order:
-
Update Embedded Knowledge Submodule
cd embedded-knowledge git pull origin main cd .. git add embedded-knowledge git commit -m "chore: update embedded-knowledge submodule to latest"
-
Run Full Test Suite (CI Simulation)
npm run test:ci
- This cleans build artifacts and runs from scratch (exactly like CI)
- All tests must pass before proceeding
-
Verify No Uncommitted Changes
git status
- Working directory should be clean
-
Update Version Number
# Choose appropriate version bump: patch, minor, or major npm version patch -m "chore: bump version to %s" # or npm version minor -m "feat: bump version to %s" # or npm version major -m "breaking: bump version to %s"
- This updates package.json and creates a git commit + tag automatically
-
Update CHANGELOG.md (if not done already)
- Document all changes since last release
- Follow Keep a Changelog format
- Include breaking changes, new features, bug fixes
-
Verify Package Contents
npm pack --dry-run
- Ensure only intended files will be published (dist/, embedded-knowledge/)
- Check package.json "files" array if needed
-
Verify NPM Authentication
npm whoami
- If not logged in:
npm login
- If not logged in:
-
Dry Run Publish
npm publish --dry-run --access public
- Review what will be published
- Check for any warnings or errors
-
Publish to NPM Registry
npm publish --access public
- Package is now live on npmjs.com
-
Push Tags and Commits
git push origin main --tags
-
Create GitHub Release (via gh CLI)
# Get the latest tag $TAG = git describe --tags --abbrev=0 # Create release with auto-generated notes gh release create $TAG --generate-notes --title "Release $TAG" # Or with custom notes from CHANGELOG gh release create $TAG --notes-file CHANGELOG.md --title "Release $TAG"
-
Verify NPM Package
npm view bc-code-intelligence-mcp version
- Should show newly published version
-
Test Installation
# In a test directory npx bc-code-intelligence-mcp@latest --version -
Verify GitHub Release
- Check https://github.com/JeremyVyska/bc-code-intelligence-mcp/releases
- Ensure release notes are correct
If a critical issue is discovered post-release:
# Deprecate the bad version
npm deprecate bc-code-intelligence-mcp@<bad-version> "Critical bug - use <good-version> instead"
# Publish a patch fix immediately
npm version patch -m "fix: critical issue from <bad-version>"
npm publish --access public| Issue | Solution |
|---|---|
| Tests pass locally but fail in CI | Run npm run test:ci before release |
| Submodule out of date | Always pull latest embedded-knowledge first |
| NPM authentication failed | Run npm login and verify with npm whoami |
| Package too large | Check .npmignore or package.json "files" array |
| Version conflict | Ensure you pulled latest tags: git pull --tags |
# Complete release workflow (copy-paste friendly)
cd embedded-knowledge && git pull origin main && cd ..
git add embedded-knowledge && git commit -m "chore: update embedded-knowledge submodule"
npm run test:ci
npm version patch -m "chore: bump version to %s"
npm publish --access public
git push origin main --tags
gh release create $(git describe --tags --abbrev=0) --generate-notes- Knowledge Source: embedded-knowledge/ submodule from bc-code-intelligence
- Client Integration: MCP protocol for AI development tools
- Layer Sources: Local overrides, git repos, HTTP endpoints (extensible)