Skip to content

Commit 0c58513

Browse files
test cases added for mcp
1 parent 3c69f29 commit 0c58513

20 files changed

+946
-1
lines changed

testcases/package.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,27 @@
3232
"test:codeparsers": "node tests/codeparsers-test.js",
3333
"test:outputparsers": "node tests/outputparsers-test.js",
3434
"test:history": "node tests/history-test.js",
35-
"test:all": "npm run test:fs && npm run test:git && npm run test:chat && npm run test:terminal && npm run test:browser && npm run test:llm && npm run test:tools && npm run test:vectordb && npm run test:websocket && npm run test:codeutils && npm run test:toolBox && npm run test:debug && npm run test:dbmemory && npm run test:crawler && npm run test:tokenizer && npm run test:task && npm run test:state && npm run test:project && npm run test:agent && npm run test:rag && npm run test:docutils && npm run test:search && npm run test:knowledge && npm run test:codeparsers && npm run test:outputparsers && npm run test:history"
35+
"test:mcp:agent": "node tests/mcp_tools/agent-mcp-test.js",
36+
"test:mcp:browser": "node tests/mcp_tools/browser-mcp-test.js",
37+
"test:mcp:chat": "node tests/mcp_tools/chat-mcp-test.js",
38+
"test:mcp:codebase": "node tests/mcp_tools/codebase-mcp-test.js",
39+
"test:mcp:code-utils": "node tests/mcp_tools/code-utils-mcp-test.js",
40+
"test:mcp:config": "node tests/mcp_tools/config-mcp-test.js",
41+
"test:mcp:debug": "node tests/mcp_tools/debug-mcp-test.js",
42+
"test:mcp:fs": "node tests/mcp_tools/fs-mcp-test.js",
43+
"test:mcp:git": "node tests/mcp_tools/git-mcp-test.js",
44+
"test:mcp:memory": "node tests/mcp_tools/memory-mcp-test.js",
45+
"test:mcp:message": "node tests/mcp_tools/message-mcp-test.js",
46+
"test:mcp:notification": "node tests/mcp_tools/notification-mcp-test.js",
47+
"test:mcp:problem-matcher": "node tests/mcp_tools/problem-matcher-mcp-test.js",
48+
"test:mcp:state": "node tests/mcp_tools/state-mcp-test.js",
49+
"test:mcp:task": "node tests/mcp_tools/task-mcp-test.js",
50+
"test:mcp:terminal": "node tests/mcp_tools/terminal-mcp-test.js",
51+
"test:mcp:tokenizer": "node tests/mcp_tools/tokenizer-mcp-test.js",
52+
"test:mcp:vector": "node tests/mcp_tools/vectordb-mcp-test.js",
53+
"test:mcp:application": "node tests/mcp_tools/application-mcp-test.js",
54+
"test:mcp:all": "node tests/mcp_tools/run-all-mcp-tests.js",
55+
"test:all": "npm run test:fs && npm run test:git && npm run test:chat && npm run test:terminal && npm run test:browser && npm run test:llm && npm run test:tools && npm run test:vectordb && npm run test:websocket && npm run test:codeutils && npm run test:toolBox && npm run test:debug && npm run test:dbmemory && npm run test:crawler && npm run test:tokenizer && npm run test:task && npm run test:state && npm run test:project && npm run test:agent && npm run test:rag && npm run test:docutils && npm run test:search && npm run test:knowledge && npm run test:codeparsers && npm run test:outputparsers && npm run test:history && npm run test:mcp:all"
3656
},
3757
"keywords": [
3858
"codebolt",
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const codebolt = require('@codebolt/codeboltjs');
2+
3+
async function testAgentMCPTools() {
4+
console.log('🤖 Testing Agent MCP Tools');
5+
console.log('==========================');
6+
await codebolt.waitForConnection();
7+
try {
8+
// 1. start
9+
try {
10+
const result = await codebolt.tools.executeTool('codebolt.agent', 'start', { agentId: 'act', task: 'Hi' });
11+
console.log('✅ start:', result?.success);
12+
} catch (e) { console.log('⚠️ start failed:', e.message); }
13+
// 2. find
14+
try {
15+
const result = await codebolt.tools.executeTool('codebolt.agent', 'find', { task: 'create node js application' });
16+
console.log('✅ find:', result?.success, 'Found:', result?.data?.length || 0);
17+
} catch (e) { console.log('⚠️ find failed:', e.message); }
18+
// 3. list
19+
try {
20+
const result = await codebolt.tools.executeTool('codebolt.agent', 'list', {});
21+
console.log('✅ list:', result?.success, 'Agents:', result?.data?.length || 0);
22+
} catch (e) { console.log('⚠️ list failed:', e.message); }
23+
// 4. get_detail (requires a real agentId)
24+
try {
25+
const result = await codebolt.tools.executeTool('codebolt.agent', 'get_detail', { agentId: 'ask' });
26+
console.log('✅ get_detail:', result?.success, 'Agent:', !!result?.data);
27+
} catch (e) { console.log('⚠️ get_detail failed:', e.message); }
28+
console.log('🎉 Agent MCP tools tests completed!');
29+
} catch (e) {
30+
console.error('❌ Agent MCP tools test error:', e.message);
31+
}
32+
}
33+
34+
testAgentMCPTools();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const codebolt = require('@codebolt/codeboltjs');
2+
3+
async function testAppServericeMCPTools() {
4+
console.log('🛠️ Testing application MCP Tools');
5+
console.log('=================================');
6+
await codebolt.waitForConnection();
7+
try {
8+
// 1. get_state
9+
try {
10+
const result = await codebolt.tools.executeTool('codebolt.application', 'get_state', {});
11+
console.log('✅ get_state:', result?.success, 'Data:', !!result?.data);
12+
} catch (e) { console.log('⚠️ get_state failed:', e.message); }
13+
// 2. get_project_state
14+
try {
15+
const result = await codebolt.tools.executeTool('codebolt.application', 'get_project_state', {});
16+
console.log('✅ get_project_state:', result?.success, 'Data:', !!result?.data);
17+
} catch (e) { console.log('⚠️ get_project_state failed:', e.message); }
18+
// 3. update_project_state
19+
try {
20+
const result = await codebolt.tools.executeTool('codebolt.application', 'update_project_state', { key: 'testKey', value: 'testValue' });
21+
console.log('✅ update_project_state:', result?.success);
22+
} catch (e) { console.log('⚠️ update_project_state failed:', e.message); }
23+
console.log('🎉 AppServerice MCP tools tests completed!');
24+
} catch (e) {
25+
console.error('❌ AppServerice MCP tools test error:', e.message);
26+
}
27+
}
28+
29+
testAppServericeMCPTools();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const codebolt = require('@codebolt/codeboltjs');
2+
3+
async function testBrowserMCPTools() {
4+
console.log('🌐 Testing Browser MCP Tools');
5+
console.log('============================');
6+
await codebolt.waitForConnection();
7+
try {
8+
// 1. browser_navigate
9+
try {
10+
const result = await codebolt.tools.executeTool('codebolt.browser', 'browser_navigate', { url: 'https://example.com' });
11+
console.log('✅ browser_navigate:', result?.success, 'URL:', result?.currentUrl);
12+
} catch (e) { console.log('⚠️ browser_navigate failed:', e.message); }
13+
// 2. browser_click
14+
try {
15+
const result = await codebolt.tools.executeTool('codebolt.browser', 'browser_click', { selector: 'body' });
16+
console.log('✅ browser_click:', result?.success);
17+
} catch (e) { console.log('⚠️ browser_click failed:', e.message); }
18+
// 3. browser_type
19+
try {
20+
const result = await codebolt.tools.executeTool('codebolt.browser', 'browser_type', { selector: 'input', text: 'test' });
21+
console.log('✅ browser_type:', result?.success);
22+
} catch (e) { console.log('⚠️ browser_type failed:', e.message); }
23+
// 4. browser_screenshot
24+
try {
25+
const result = await codebolt.tools.executeTool('codebolt.browser', 'browser_screenshot', { fullPage: true });
26+
console.log('✅ browser_screenshot:', result?.success, 'Screenshot:', !!result?.screenshot);
27+
} catch (e) { console.log('⚠️ browser_screenshot failed:', e.message); }
28+
// 5. browser_get_content
29+
try {
30+
const result = await codebolt.tools.executeTool('codebolt.browser', 'browser_get_content', {});
31+
console.log('✅ browser_get_content:', result?.success, 'Content:', !!result?.content);
32+
} catch (e) { console.log('⚠️ browser_get_content failed:', e.message); }
33+
// 6. browser_scroll
34+
try {
35+
const result = await codebolt.tools.executeTool('codebolt.browser', 'browser_scroll', { direction: 'down', amount: 100 });
36+
console.log('✅ browser_scroll:', result?.success);
37+
} catch (e) { console.log('⚠️ browser_scroll failed:', e.message); }
38+
console.log('🎉 Browser MCP tools tests completed!');
39+
} catch (e) {
40+
console.error('❌ Browser MCP tools test error:', e.message);
41+
}
42+
}
43+
44+
testBrowserMCPTools();
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const codebolt = require('@codebolt/codeboltjs');
2+
3+
async function testCodeUtilsMCPTools() {
4+
console.log('🧩 Testing CodeUtils MCP Tools');
5+
console.log('==============================');
6+
await codebolt.waitForConnection();
7+
try {
8+
// 1. get_files_markdown
9+
try {
10+
const result = await codebolt.tools.executeTool('codebolt.code_utils', 'get_files_markdown', {});
11+
console.log('✅ get_files_markdown:', result?.success, 'Data:', !!result?.data);
12+
} catch (e) { console.log('⚠️ get_files_markdown failed:', e.message); }
13+
// 2. get_js_tree
14+
try {
15+
const result = await codebolt.tools.executeTool('codebolt.code_utils', 'get_js_tree', { filePath: './tests/terminal-test.js' });
16+
console.log('✅ get_js_tree:', result?.success, 'Data:', !!result?.data);
17+
} catch (e) { console.log('⚠️ get_js_tree failed:', e.message); }
18+
// 3. perform_match
19+
try {
20+
const matcherDefinition = {
21+
owner: "eslint-compact",
22+
pattern: [{
23+
regexp: "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
24+
file: 1,
25+
line: 2,
26+
column: 3,
27+
severity: 4,
28+
message: 5,
29+
code: 6
30+
}]
31+
};
32+
const testProblems = [
33+
{ line: "src/file1.js: line 10, col 5, Error - Unexpected console statement (no-console)", source: "test" },
34+
{ line: "src/file2.js: line 25, col 8, Warning - 'var' used instead of 'let' or 'const' (no-var)", source: "test" },
35+
{ line: "This should not match", source: "test" },
36+
{},
37+
{ line: "src/file3.js: line 5, col 15, Info - Missing JSDoc comment (require-jsdoc)", source: "test" }
38+
];
39+
const result = await codebolt.tools.executeTool('codebolt.code_utils', 'perform_match', { matcherDefinition, pattern: matcherDefinition.pattern, problems: testProblems });
40+
console.log('✅ perform_match:', result?.success);
41+
} catch (e) { console.log('⚠️ perform_match failed:', e.message); }
42+
// 4. get_matcher_list
43+
try {
44+
const result = await codebolt.tools.executeTool('codebolt.code_utils', 'get_matcher_list', {});
45+
console.log('✅ get_matcher_list:', result?.success, 'List:', result?.list?.length || 0);
46+
} catch (e) { console.log('⚠️ get_matcher_list failed:', e.message); }
47+
// 5. get_match_detail
48+
try {
49+
const result = await codebolt.tools.executeTool('codebolt.code_utils', 'get_match_detail', { matcherId: 'xmllint' });
50+
console.log('✅ get_match_detail:', result?.success, 'Detail:', !!result?.detail);
51+
} catch (e) { console.log('⚠️ get_match_detail failed:', e.message); }
52+
console.log('🎉 CodeUtils MCP tools tests completed!');
53+
} catch (e) {
54+
console.error('❌ CodeUtils MCP tools test error:', e.message);
55+
}
56+
}
57+
58+
testCodeUtilsMCPTools();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const codebolt = require('@codebolt/codeboltjs');
2+
3+
async function testCrawlerMCPTools() {
4+
console.log('🕷️ Testing Crawler MCP Tools');
5+
console.log('============================');
6+
await codebolt.waitForConnection();
7+
try {
8+
// 1. crawler_crawl
9+
try {
10+
const result = await codebolt.tools.executeTool('codebolt.crawler', 'crawler_crawl', { url: 'https://example.com' });
11+
console.log('✅ crawler_crawl:', result?.success, 'Data:', !!result?.data);
12+
} catch (e) { console.log('⚠️ crawler_crawl failed:', e.message); }
13+
console.log('🎉 Crawler MCP tools tests completed!');
14+
} catch (e) {
15+
console.error('❌ Crawler MCP tools test error:', e.message);
16+
}
17+
}
18+
19+
testCrawlerMCPTools();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const codebolt = require('@codebolt/codeboltjs');
2+
3+
async function testDebugMCPTools() {
4+
console.log('🐞 Testing Debug MCP Tools');
5+
console.log('========================');
6+
await codebolt.waitForConnection();
7+
try {
8+
9+
try {
10+
const result = await codebolt.tools.executeTool('codebolt.debug', 'debug_open_browser', { url: 'https://example.com', port: 3000 });
11+
console.log('✅ debug_open_browser:', result?.success);
12+
} catch (e) { console.log('⚠️ debug_open_browser failed:', e.message); }
13+
console.log('🎉 Debug MCP tools tests completed!');
14+
} catch (e) {
15+
console.error('❌ Debug MCP tools test error:', e.message);
16+
}
17+
}
18+
19+
testDebugMCPTools();
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const codebolt = require('@codebolt/codeboltjs');
2+
3+
async function testFSMCPTools() {
4+
console.log('📁 Testing FS MCP Tools');
5+
console.log('=======================');
6+
await codebolt.waitForConnection();
7+
try {
8+
// 1. read_file
9+
try {
10+
const result = await codebolt.tools.executeTool('codebolt.fs', 'read_file', { path: './README.md' });
11+
console.log('✅ read_file:', result?.success, result?.content ? 'Content loaded' : 'No content');
12+
} catch (e) { console.log('⚠️ read_file failed:', e.message); }
13+
// 2. list_files
14+
try {
15+
const result = await codebolt.tools.executeTool('codebolt.fs', 'list_files',{path: './'});
16+
console.log('✅ list_files:', result?.success, 'Files:', result?.files?.length || 0);
17+
} catch (e) { console.log('⚠️ list_files failed:', e.message); }
18+
// 3. write_file
19+
try {
20+
const result = await codebolt.tools.executeTool('codebolt.fs', 'write_file', { path: './test-fs-mcp.txt', content: 'test' });
21+
console.log('✅ write_file:', result?.success);
22+
} catch (e) { console.log('⚠️ write_file failed:', e.message); }
23+
24+
// 5. grep_search
25+
try {
26+
const result = await codebolt.tools.executeTool('codebolt.fs', 'grep_search', { pattern: 'test', path: './' });
27+
console.log('✅ grep_search:', result?.success, 'Matches:', result?.matches?.length || 0);
28+
} catch (e) { console.log('⚠️ grep_search failed:', e.message); }
29+
// 6. search_files
30+
try {
31+
const result = await codebolt.tools.executeTool('codebolt.fs', 'search_files', { pattern: 'test', path: './' });
32+
console.log('✅ search_files:', result?.success, 'Files:', result?.files?.length || 0);
33+
} catch (e) { console.log('⚠️ search_files failed:', e.message); }
34+
// 7. list_code_definitions
35+
try {
36+
const result = await codebolt.tools.executeTool('codebolt.fs', 'list_code_definitions', { path: './src/index.js' });
37+
console.log('✅ list_code_definitions:', result?.success, 'Defs:', result?.definitions?.length || 0);
38+
} catch (e) { console.log('⚠️ list_code_definitions failed:', e.message); }
39+
console.log('🎉 FS MCP tools tests completed!');
40+
} catch (e) {
41+
console.error('❌ FS MCP tools test error:', e.message);
42+
}
43+
}
44+
45+
testFSMCPTools();
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
const codebolt = require('@codebolt/codeboltjs');
2+
3+
async function testGitMCPTools() {
4+
console.log('🔀 Testing Git MCP Tools');
5+
console.log('========================');
6+
await codebolt.waitForConnection();
7+
try {
8+
// 1. git_init
9+
try {
10+
const result = await codebolt.tools.executeTool('codebolt.git', 'git_init', { dir: './' });
11+
console.log('✅ git_init:', result?.success);
12+
} catch (e) { console.log('⚠️ git_init failed:', e.message); }
13+
// 2. git_add
14+
try {
15+
const result = await codebolt.tools.executeTool('codebolt.git', 'git_add', { files: ['test.txt'] });
16+
console.log('✅ git_add:', result?.success);
17+
} catch (e) { console.log('⚠️ git_add failed:', e.message); }
18+
// 3. git_commit
19+
try {
20+
const result = await codebolt.tools.executeTool('codebolt.git', 'git_commit', { message: 'Test commit' });
21+
console.log('✅ git_commit:', result?.success);
22+
} catch (e) { console.log('⚠️ git_commit failed:', e.message); }
23+
// 4. git_push
24+
try {
25+
const result = await codebolt.tools.executeTool('codebolt.git', 'git_push', {});
26+
console.log('✅ git_push:', result?.success);
27+
} catch (e) { console.log('⚠️ git_push failed:', e.message); }
28+
// 5. git_pull
29+
try {
30+
const result = await codebolt.tools.executeTool('codebolt.git', 'git_pull', {});
31+
console.log('✅ git_pull:', result?.success);
32+
} catch (e) { console.log('⚠️ git_pull failed:', e.message); }
33+
// 6. git_checkout (requires a real branch name)
34+
try {
35+
const result = await codebolt.tools.executeTool('codebolt.git', 'git_checkout', { branch: 'main' });
36+
console.log('✅ git_checkout:', result?.success);
37+
} catch (e) { console.log('⚠️ git_checkout failed:', e.message); }
38+
// 7. git_branch (requires a new branch name)
39+
try {
40+
const result = await codebolt.tools.executeTool('codebolt.git', 'git_branch', { branch: 'test-branch' });
41+
console.log('✅ git_branch:', result?.success);
42+
} catch (e) { console.log('⚠️ git_branch failed:', e.message); }
43+
// 8. git_logs
44+
try {
45+
const result = await codebolt.tools.executeTool('codebolt.git', 'git_logs', {});
46+
console.log('✅ git_logs:', result?.success, 'Logs:', result?.data?.length || 0);
47+
} catch (e) { console.log('⚠️ git_logs failed:', e.message); }
48+
// 9. git_diff (requires a real commit hash)
49+
try {
50+
const result = await codebolt.tools.executeTool('codebolt.git', 'git_diff', { commitHash: 'HEAD~1' });
51+
console.log('✅ git_diff:', result?.success, 'Diff:', !!result?.data);
52+
} catch (e) { console.log('⚠️ git_diff failed:', e.message); }
53+
// 10. git_status
54+
try {
55+
const result = await codebolt.tools.executeTool('codebolt.git', 'git_status', {});
56+
console.log('✅ git_status:', result?.success, 'Status:', result?.data);
57+
} catch (e) { console.log('⚠️ git_status failed:', e.message); }
58+
// 11. git_clone (requires a real repo URL)
59+
try {
60+
const result = await codebolt.tools.executeTool('codebolt.git', 'git_clone', { url: 'https://github.com/user/repo.git' });
61+
console.log('✅ git_clone:', result?.success);
62+
} catch (e) { console.log('⚠️ git_clone failed:', e.message); }
63+
console.log('🎉 Git MCP tools tests completed!');
64+
} catch (e) {
65+
console.error('❌ Git MCP tools test error:', e.message);
66+
}
67+
}
68+
69+
testGitMCPTools();

0 commit comments

Comments
 (0)