MCPcopy Create free account
hub / github.com/Noumena-Network/code / createPythonReplTool

Function createPythonReplTool

src/tools/REPLTool/pyReplFactory.tsx:564–717  ·  view source on GitHub ↗
(config: PythonReplToolConfig)

Source from the content-addressed store, hash-verified

562}
563
564export function createPythonReplTool(config: PythonReplToolConfig) {
565 const inputSchema = buildInputSchema(config.inputSchemaDescription)
566 const outputSchema = buildOutputSchema()
567 const hiddenToolNames = new Set(config.forbiddenNestedToolNames ?? [])
568
569 return buildTool({
570 name: config.toolName,
571 searchHint: config.searchHint,
572 maxResultSizeChars: Infinity,
573 async description() {
574 return config.description
575 },
576 get inputSchema() {
577 return inputSchema()
578 },
579 get outputSchema() {
580 return outputSchema()
581 },
582 isReadOnly() {
583 return false
584 },
585 toAutoClassifierInput(input) {
586 return input.code
587 },
588 async checkPermissions(input, context): Promise<PermissionResult> {
589 const mode = context.getAppState().toolPermissionContext.mode
590 if (mode === 'acceptEdits') {
591 return {
592 behavior: 'allow',
593 updatedInput: input,
594 decisionReason: {
595 type: 'mode',
596 mode,
597 },
598 }
599 }
600 return {
601 behavior: 'passthrough',
602 updatedInput: input,
603 }
604 },
605 async prompt() {
606 return typeof config.prompt === 'function' ? config.prompt() : config.prompt
607 },
608 userFacingName() {
609 return config.userFacingName
610 },
611 renderToolUseMessage(input) {
612 const compact = input.code.replace(/\s+/g, ' ').trim()
613 if (!compact) {
614 return 'script'
615 }
616 return preview(compact, 120)
617 },
618 renderToolUseProgressMessage(progressMessages) {
619 const latest = [...progressMessages]
620 .reverse()
621 .find(

Callers 1

PyReplTool.tsxFile · 0.85

Calls 3

buildToolFunction · 0.85
buildInputSchemaFunction · 0.70
buildOutputSchemaFunction · 0.70

Tested by

no test coverage detected