Skip to content

Commit 0a60da4

Browse files
committed
extended tool API & patterns
1 parent a1ab8d4 commit 0a60da4

File tree

6 files changed

+24
-11
lines changed

6 files changed

+24
-11
lines changed

libs/remix-ai-core/src/inferencers/mcp/codeExecutor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class CodeExecutor {
4949

5050
try {
5151
this.validateCode(code);
52+
console.log('[MCP Code mode] - Executing code \n', code)
5253
const context = this.createExecutionContext();
5354
const result = await this.executeWithTimeout(code, context);
5455
const executionTime = Date.now() - startTime;
@@ -78,8 +79,6 @@ export class CodeExecutor {
7879
private validateCode(code: string): void {
7980
// Check for dangerous patterns
8081
const dangerousPatterns = [
81-
/\brequire\s*\(/,
82-
/\bimport\s+/,
8382
/\bprocess\./,
8483
/\b__dirname\b/,
8584
/\b__filename\b/,

libs/remix-ai-core/src/inferencers/mcp/mcpInferencer.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,10 +772,7 @@ ${toolsList}`,
772772
throw new Error(`Tool '${innerToolCall.name}' not found in any connected MCP server`);
773773
}
774774

775-
console.log(`[MCP Code Mode] Executing tool ${innerToolCall.name} from server ${targetServer}`);
776775
const result = await this.executeTool(targetServer, innerToolCall);
777-
console.log(`[MCP Code Mode] inner tool ${innerToolCall.name} produced result`)
778-
console.log(result)
779776
return result
780777
},
781778
30000 // 30 second timeout

libs/remix-ai-core/src/inferencers/mcp/toolApiGenerator.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,33 @@ export class ToolApiGenerator {
88
generateAPIDescription(): string {
99
return `
1010
Use callMCPTool(toolName, args) to call tools. You can perform multiple tasks by chaining tool calls.
11+
Each callMCPTool returns a object according to this interface
12+
export interface IMCPToolResult {
13+
content: Array<{
14+
type: 'text' | 'image' | 'resource';
15+
text?: string;
16+
data?: string;
17+
mimeType?: string;
18+
}>;
19+
isError?: boolean;
20+
}
1121
1222
Examples:
13-
// Single task
14-
const file = await callMCPTool('file_read', { path: 'contract.sol' });
23+
// Reading files - returns string content directly
24+
const fileContent = await callMCPTool('file_read', { path: 'contract.sol' });
25+
const modified = fileContent.replace('old', 'new');
1526
16-
// Multiple tasks
27+
// Multiple tasks 1
1728
const compiled = await callMCPTool('solidity_compile', { file: 'contract.sol' });
1829
const deployed = await callMCPTool('deploy_contract', { contractName: 'MyToken' });
1930
31+
// Multiple tasks 2
32+
const fileContent = await callMCPTool('file_read', { path:'contract.sol' });
33+
const content = JSON.parse(fileContent.content[0].text).content
34+
const updatedContent = fileContent.replace('contract Subscription', 'contract MySubscriptionContract');
35+
await callMCPTool('file_write', { path: 'ccontract.sol', content: updatedContent });
36+
37+
2038
// With loops for batch operations
2139
const files = ['contracts/Token.sol', 'contracts/NFT.sol', 'contracts/DAO.sol'];
2240
for (const file of files) {

libs/remix-ai-core/src/remix-mcp-server/handlers/DeploymentHandler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ export class DeployContractHandler extends BaseToolHandler {
136136
}
137137

138138
const receipt = (txReturn.txResult.receipt)
139-
console.log("receipt is", receipt)
140139
const result: DeploymentResult = {
141140
transactionHash: receipt.hash,
142141
gasUsed: toNumber(receipt.gasUsed),

libs/remix-ui/helper/src/lib/components/remix-md-renderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function RemixMdRenderer({ markDownContent, theme }: { markDownContent: s
9595
ol: ({ node, ...props }) => (
9696
<ol className="ai-list ai-list-ordered" {...props} />
9797
),
98-
li: ({ node, ...props }) => (
98+
li: ({ node, ordered, ...props }) => (
9999
<li className="ai-list-item" {...props} />
100100
),
101101
// Links

libs/remix-ui/remix-ai-assistant/src/components/chat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ function RemixMarkdownViewer(theme: string, markDownContent: string): React.Reac
246246
ol: ({ node, ...props }) => (
247247
<ol className="ai-list ai-list-ordered" {...props} />
248248
),
249-
li: ({ node, ...props }) => (
249+
li: ({ node, ordered, ...props }) => (
250250
<li className="ai-list-item" {...props} />
251251
),
252252
// Links

0 commit comments

Comments
 (0)