vibecheck-mcp-server 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/test-mcp.js ADDED
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MCP Server Test Script
4
+ * Tests that all tools are properly registered and can be invoked
5
+ */
6
+
7
+ import { spawn } from 'child_process';
8
+ import { fileURLToPath } from 'url';
9
+ import path from 'path';
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+
14
+ console.log('๐Ÿงช Testing Guardrail MCP Server...\n');
15
+
16
+ // Test 1: Import all modules
17
+ async function testImports() {
18
+ console.log('1๏ธโƒฃ Testing module imports...');
19
+ try {
20
+ const { INTELLIGENCE_TOOLS } = await import('./intelligence-tools.js');
21
+ const { GUARDRAIL_TOOLS } = await import('./guardrail-tools.js');
22
+ const { AGENT_CHECKPOINT_TOOLS } = await import('./agent-checkpoint.js');
23
+ const { ARCHITECT_TOOLS } = await import('./architect-tools.js');
24
+ const { CODEBASE_ARCHITECT_TOOLS } = await import('./codebase-architect-tools.js');
25
+ const { GUARDRAIL_2_TOOLS } = await import('./guardrail-2.0-tools.js');
26
+ const { intentDriftTools } = await import('./intent-drift-tools.js');
27
+ const { mdcGeneratorTool } = await import('./mdc-generator.js');
28
+
29
+ console.log(` โœ… Intelligence tools: ${INTELLIGENCE_TOOLS.length}`);
30
+ console.log(` โœ… Guardrail tools: ${GUARDRAIL_TOOLS.length}`);
31
+ console.log(` โœ… Checkpoint tools: ${AGENT_CHECKPOINT_TOOLS.length}`);
32
+ console.log(` โœ… Architect tools: ${ARCHITECT_TOOLS.length}`);
33
+ console.log(` โœ… Codebase Architect tools: ${CODEBASE_ARCHITECT_TOOLS.length}`);
34
+ console.log(` โœ… Guardrail 2.0 tools: ${GUARDRAIL_2_TOOLS.length}`);
35
+ console.log(` โœ… Intent Drift tools: ${intentDriftTools.length}`);
36
+ console.log(` โœ… MDC Generator tool: ${mdcGeneratorTool.name}`);
37
+
38
+ const totalTools = INTELLIGENCE_TOOLS.length + GUARDRAIL_TOOLS.length +
39
+ AGENT_CHECKPOINT_TOOLS.length + ARCHITECT_TOOLS.length +
40
+ CODEBASE_ARCHITECT_TOOLS.length + GUARDRAIL_2_TOOLS.length +
41
+ intentDriftTools.length + 1;
42
+
43
+ console.log(`\n ๐Ÿ“Š Total tools available: ${totalTools}\n`);
44
+ return true;
45
+ } catch (error) {
46
+ console.log(` โŒ Import failed: ${error.message}`);
47
+ return false;
48
+ }
49
+ }
50
+
51
+ // Test 2: Verify tier auth
52
+ async function testTierAuth() {
53
+ console.log('2๏ธโƒฃ Testing tier authentication...');
54
+ try {
55
+ const tierAuth = await import('./tier-auth.js');
56
+ console.log(` โœ… Tiers available: ${Object.keys(tierAuth.TIERS).join(', ')}`);
57
+ console.log(` โœ… Tier auth module loaded successfully`);
58
+ return true;
59
+ } catch (error) {
60
+ console.log(` โŒ Tier auth failed: ${error.message}`);
61
+ return false;
62
+ }
63
+ }
64
+
65
+ // Test 3: Verify audit trail
66
+ async function testAudit() {
67
+ console.log('3๏ธโƒฃ Testing audit trail...');
68
+ try {
69
+ const { emitToolInvoke, emitToolComplete } = await import('./audit-mcp.js');
70
+ console.log(` โœ… Audit functions available`);
71
+ return true;
72
+ } catch (error) {
73
+ console.log(` โŒ Audit failed: ${error.message}`);
74
+ return false;
75
+ }
76
+ }
77
+
78
+ // Run all tests
79
+ async function runTests() {
80
+ const results = [];
81
+
82
+ results.push(await testImports());
83
+ results.push(await testTierAuth());
84
+ results.push(await testAudit());
85
+
86
+ console.log('\n' + '='.repeat(50));
87
+ const passed = results.filter(r => r).length;
88
+ const total = results.length;
89
+
90
+ if (passed === total) {
91
+ console.log(`โœ… All ${total} tests passed!`);
92
+ console.log('\n๐ŸŽ‰ MCP Server is ready for use!\n');
93
+ console.log('To use with Claude Desktop, add to claude_desktop_config.json:');
94
+ console.log(`{
95
+ "mcpServers": {
96
+ "guardrail": {
97
+ "command": "node",
98
+ "args": ["${__dirname.replace(/\\/g, '/')}/index.js"]
99
+ }
100
+ }
101
+ }`);
102
+ } else {
103
+ console.log(`โŒ ${total - passed}/${total} tests failed`);
104
+ process.exit(1);
105
+ }
106
+ }
107
+
108
+ runTests().catch(console.error);
package/test-tools.js ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Test individual MCP tools
4
+ */
5
+
6
+ import { GUARDRAIL_TOOLS } from './guardrail-tools.js';
7
+ import { INTELLIGENCE_TOOLS } from './intelligence-tools.js';
8
+
9
+ console.log('๐Ÿ”ง Testing MCP Server Tools...\n');
10
+
11
+ // List all available tools
12
+ console.log('Available Guardrail Tools:');
13
+ GUARDRAIL_TOOLS.forEach(tool => {
14
+ console.log(` - ${tool.name}: ${tool.description}`);
15
+ });
16
+
17
+ console.log('\nAvailable Intelligence Tools:');
18
+ INTELLIGENCE_TOOLS.forEach(tool => {
19
+ console.log(` - ${tool.name}: ${tool.description}`);
20
+ });
21
+
22
+ // Test a simple tool function
23
+ console.log('\n๐Ÿงช Testing tool execution...');
24
+
25
+ // Test guardrail.mdc function
26
+ try {
27
+ const { handleGuardrailTool } = await import('./guardrail-tools.js');
28
+ const result = await handleGuardrailTool('guardrail.mdc', {
29
+ path: process.cwd(),
30
+ output: 'test-output.mdc'
31
+ });
32
+ console.log('โœ… guardrail.mdc tool executed successfully');
33
+ console.log('Result:', JSON.stringify(result, null, 2));
34
+ } catch (error) {
35
+ console.log('โŒ Tool execution failed:', error.message);
36
+ }
package/tier-auth.js ADDED
@@ -0,0 +1,147 @@
1
+ /**
2
+ * MCP Server Tier Authentication & Authorization
3
+ *
4
+ * Provides tier checking for MCP tools based on API keys
5
+ */
6
+
7
+ import fs from "fs/promises";
8
+ import path from "path";
9
+ import os from "os";
10
+
11
+ // Tier definitions
12
+ export const TIERS = {
13
+ free: {
14
+ name: 'Free',
15
+ features: ['verify', 'quality', 'hallucination'],
16
+ limits: { scans: 10, projects: 1 }
17
+ },
18
+ starter: {
19
+ name: 'Starter',
20
+ features: ['verify', 'quality', 'hallucination', 'smells', 'breaking'],
21
+ limits: { scans: 100, projects: 3 }
22
+ },
23
+ pro: {
24
+ name: 'Professional',
25
+ features: ['verify', 'quality', 'hallucination', 'smells', 'breaking', 'mdc'],
26
+ limits: { scans: 1000, projects: 10 }
27
+ },
28
+ enterprise: {
29
+ name: 'Enterprise',
30
+ features: ['verify', 'quality', 'hallucination', 'smells', 'breaking', 'mdc'],
31
+ limits: { scans: -1, projects: -1 } // unlimited
32
+ }
33
+ };
34
+
35
+ /**
36
+ * Load user configuration from ~/.guardrail/credentials.json
37
+ */
38
+ async function loadUserConfig() {
39
+ try {
40
+ const configPath = path.join(os.homedir(), '.guardrail', 'credentials.json');
41
+ const configData = await fs.readFile(configPath, 'utf-8');
42
+ return JSON.parse(configData);
43
+ } catch (error) {
44
+ return null;
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Determine tier from API key
50
+ */
51
+ function getTierFromApiKey(apiKey) {
52
+ if (!apiKey) return 'free';
53
+
54
+ if (apiKey.startsWith('gr_starter_')) return 'starter';
55
+ if (apiKey.startsWith('gr_pro_')) return 'pro';
56
+ if (apiKey.startsWith('gr_ent_')) return 'enterprise';
57
+ if (apiKey.startsWith('gr_free_')) return 'free';
58
+
59
+ return 'free'; // default for unknown keys
60
+ }
61
+
62
+ /**
63
+ * Check if user has access to a specific feature
64
+ */
65
+ export async function checkFeatureAccess(featureName, providedApiKey = null) {
66
+ // Try to load user config
67
+ const userConfig = await loadUserConfig();
68
+ const apiKey = providedApiKey || userConfig?.apiKey;
69
+
70
+ if (!apiKey) {
71
+ return {
72
+ hasAccess: false,
73
+ tier: 'free',
74
+ reason: 'No API key provided. Run: guardrail auth --key YOUR_API_KEY',
75
+ upgradeUrl: 'https://guardrail.dev/pricing'
76
+ };
77
+ }
78
+
79
+ const tier = getTierFromApiKey(apiKey);
80
+ const tierConfig = TIERS[tier];
81
+
82
+ if (!tierConfig.features.includes(featureName)) {
83
+ const requiredTier = Object.entries(TIERS).find(([_, config]) =>
84
+ config.features.includes(featureName)
85
+ )?.[0];
86
+
87
+ return {
88
+ hasAccess: false,
89
+ tier,
90
+ reason: `${featureName} requires ${requiredTier} tier or higher`,
91
+ upgradeUrl: 'https://guardrail.dev/pricing'
92
+ };
93
+ }
94
+
95
+ return {
96
+ hasAccess: true,
97
+ tier,
98
+ reason: 'Access granted'
99
+ };
100
+ }
101
+
102
+ /**
103
+ * Middleware for MCP tool handlers
104
+ */
105
+ export function withTierCheck(featureName, handler) {
106
+ return async (args) => {
107
+ const access = await checkFeatureAccess(featureName, args?.apiKey);
108
+
109
+ if (!access.hasAccess) {
110
+ return {
111
+ content: [{
112
+ type: "text",
113
+ text: `๐Ÿšซ UPGRADE REQUIRED\n\n${access.reason}\n\nUpgrade at: ${access.upgradeUrl}`
114
+ }],
115
+ isError: true
116
+ };
117
+ }
118
+
119
+ // Add tier info to args for the handler
120
+ args._tier = access.tier;
121
+ return handler(args);
122
+ };
123
+ }
124
+
125
+ /**
126
+ * Get current user info
127
+ */
128
+ export async function getUserInfo() {
129
+ const config = await loadUserConfig();
130
+ if (!config) {
131
+ return {
132
+ authenticated: false,
133
+ tier: 'free',
134
+ message: 'Not authenticated. Run: guardrail auth --key YOUR_API_KEY'
135
+ };
136
+ }
137
+
138
+ const tier = getTierFromApiKey(config.apiKey);
139
+ return {
140
+ authenticated: true,
141
+ tier,
142
+ email: config.email,
143
+ authenticatedAt: config.authenticatedAt,
144
+ features: TIERS[tier].features,
145
+ limits: TIERS[tier].limits
146
+ };
147
+ }