feat(profiles): Add MCP configuration to Claude Code rules (#980)

* add .mcp.json with claude profile

* add changeset

* update changeset

* update test
This commit is contained in:
Joe Danziger
2025-07-16 03:07:33 -04:00
committed by GitHub
parent 36dc129328
commit cc4fe205fb
7 changed files with 149 additions and 66 deletions

View File

@@ -3,6 +3,7 @@ import {
getRulesProfile
} from '../../../src/utils/rule-transformer.js';
import { RULE_PROFILES } from '../../../src/constants/profiles.js';
import path from 'path';
describe('Rule Transformer - General', () => {
describe('Profile Configuration Validation', () => {
@@ -166,19 +167,13 @@ describe('Rule Transformer - General', () => {
// Check types based on MCP configuration
expect(typeof profileConfig.mcpConfig).toBe('boolean');
if (profileConfig.mcpConfig === false) {
// Profiles without MCP configuration
expect(profileConfig.mcpConfigName).toBe(null);
expect(profileConfig.mcpConfigPath).toBe(null);
} else {
// Profiles with MCP configuration
expect(typeof profileConfig.mcpConfigName).toBe('string');
expect(typeof profileConfig.mcpConfigPath).toBe('string');
if (profileConfig.mcpConfig !== false) {
// Check that mcpConfigPath is properly constructed
expect(profileConfig.mcpConfigPath).toBe(
`${profileConfig.profileDir}/${profileConfig.mcpConfigName}`
const expectedPath = path.join(
profileConfig.profileDir,
profileConfig.mcpConfigName
);
expect(profileConfig.mcpConfigPath).toBe(expectedPath);
}
});
});
@@ -186,9 +181,9 @@ describe('Rule Transformer - General', () => {
it('should have correct MCP configuration for each profile', () => {
const expectedConfigs = {
claude: {
mcpConfig: false,
mcpConfigName: null,
expectedPath: null
mcpConfig: true,
mcpConfigName: '.mcp.json',
expectedPath: '.mcp.json'
},
cline: {
mcpConfig: false,
@@ -245,25 +240,19 @@ describe('Rule Transformer - General', () => {
it('should have consistent profileDir and mcpConfigPath relationship', () => {
RULE_PROFILES.forEach((profile) => {
const profileConfig = getRulesProfile(profile);
if (profileConfig.mcpConfig === false) {
// Profiles without MCP configuration have null mcpConfigPath
expect(profileConfig.mcpConfigPath).toBe(null);
} else {
if (profileConfig.mcpConfig !== false) {
// Profiles with MCP configuration should have valid paths
// The mcpConfigPath should start with the profileDir
expect(profileConfig.mcpConfigPath).toMatch(
new RegExp(
`^${profileConfig.profileDir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/`
)
);
// The mcpConfigPath should end with the mcpConfigName
expect(profileConfig.mcpConfigPath).toMatch(
new RegExp(
`${profileConfig.mcpConfigName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`
)
);
if (profile === 'claude') {
// Claude uses root directory (.), so path.join('.', '.mcp.json') = '.mcp.json'
expect(profileConfig.mcpConfigPath).toBe('.mcp.json');
} else {
expect(profileConfig.mcpConfigPath).toMatch(
new RegExp(
`^${profileConfig.profileDir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/`
)
);
}
}
});
});