Skip to content

Commit 9f6081c

Browse files
author
ci-bot
committed
add runscript tool
1 parent 503b3db commit 9f6081c

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

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

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import {
1212
SendTransactionArgs,
1313
DeploymentResult,
1414
AccountInfo,
15-
ContractInteractionResult
15+
ContractInteractionResult,
16+
RunScriptArgs,
17+
RunScriptResult
1618
} from '../types/mcpTools';
1719
import { Plugin } from '@remixproject/engine';
1820
import { getContractData } from '@remix-project/core-plugin'
@@ -316,6 +318,51 @@ export class CallContractHandler extends BaseToolHandler {
316318
}
317319
}
318320

321+
/**
322+
* Run Script
323+
*/
324+
export class RunScriptHandler extends BaseToolHandler {
325+
name = 'send_transaction';
326+
description = 'Run a script in the current environment';
327+
inputSchema = {
328+
type: 'object',
329+
properties: {
330+
file: {
331+
type: 'string',
332+
description: 'path to the file',
333+
pattern: '^0x[a-fA-F0-9]{40}$'
334+
}
335+
},
336+
required: ['file']
337+
};
338+
339+
getPermissions(): string[] {
340+
return ['transaction:send'];
341+
}
342+
343+
validate(args: RunScriptArgs): boolean | string {
344+
const required = this.validateRequired(args, ['file']);
345+
if (required !== true) return required;
346+
347+
return true;
348+
}
349+
350+
async execute(args: RunScriptArgs, plugin: Plugin): Promise<IMCPToolResult> {
351+
try {
352+
const content = await plugin.call('fileManager', 'readFile', args.file)
353+
await plugin.call('scriptRunnerBridge', 'execute', content, args.file)
354+
355+
const result: RunScriptResult = {}
356+
357+
return this.createSuccessResult(result);
358+
359+
} catch (error) {
360+
console.log(error)
361+
return this.createErrorResult(`Run script failed: ${error.message}`);
362+
}
363+
}
364+
}
365+
319366
/**
320367
* Send Transaction Tool Handler
321368
*/
@@ -831,6 +878,14 @@ export function createDeploymentTools(): RemixToolDefinition[] {
831878
category: ToolCategory.DEPLOYMENT,
832879
permissions: ['environment:read'],
833880
handler: new GetCurrentEnvironmentHandler()
881+
},
882+
{
883+
name: 'run_script',
884+
description: 'Run a script in the current environment',
885+
inputSchema: new RunScriptHandler().inputSchema,
886+
category: ToolCategory.DEPLOYMENT,
887+
permissions: ['transaction:send'],
888+
handler: new RunScriptHandler()
834889
}
835890
];
836891
}

libs/remix-ai-core/src/remix-mcp-server/types/mcpTools.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ export interface SendTransactionArgs {
133133
account?: string;
134134
}
135135

136+
export interface RunScriptArgs {
137+
file: string
138+
}
139+
136140
export interface DebugSessionArgs {
137141
transactionHash?: string;
138142
}
@@ -259,6 +263,8 @@ export interface DeploymentResult {
259263
logs: any[];
260264
}
261265

266+
export interface RunScriptResult {}
267+
262268
export interface ContractInteractionResult {
263269
success: boolean;
264270
result?: any;

0 commit comments

Comments
 (0)