refactor(mcp): Use BlockUIType.MCP_TOOL instead of SpecialBlockID checks

Add MCP_TOOL to backend BlockType enum and frontend BlockUIType enum,
matching the existing pattern used by AGENT blocks. Replace all
SpecialBlockID.MCP_TOOL type-checks with uiType-based checks.
This commit is contained in:
Zamil Majdy
2026-02-11 07:10:22 +04:00
parent 99a3891bb6
commit 3263d50f4b
9 changed files with 13 additions and 13 deletions

View File

@@ -131,7 +131,7 @@ class MCPToolBlock(Block):
categories={BlockCategory.DEVELOPER_TOOLS},
input_schema=MCPToolBlock.Input,
output_schema=MCPToolBlock.Output,
block_type=BlockType.STANDARD,
block_type=BlockType.MCP_TOOL,
test_credentials=TEST_CREDENTIALS,
test_input={
"server_url": "https://mcp.example.com/mcp",

View File

@@ -74,6 +74,7 @@ class BlockType(Enum):
AI = "AI"
AYRSHARE = "Ayrshare"
HUMAN_IN_THE_LOOP = "Human In The Loop"
MCP_TOOL = "MCP Tool"
class BlockCategory(Enum):

View File

@@ -3,8 +3,6 @@ import { CustomNodeData } from "./CustomNode";
import { BlockUIType } from "../../../types";
import { useMemo } from "react";
import { mergeSchemaForResolution } from "./helpers";
import { SpecialBlockID } from "@/lib/autogpt-server-api";
/**
* Build a dynamic input schema for MCP blocks.
*
@@ -50,7 +48,7 @@ export const useCustomNode = ({
const isAgent = data.uiType === BlockUIType.AGENT;
const isMCPWithTool =
data.block_id === SpecialBlockID.MCP_TOOL &&
data.uiType === BlockUIType.MCP_TOOL &&
!!data.hardcodedValues?.tool_input_schema?.properties;
const currentInputSchema = isAgent

View File

@@ -9,7 +9,7 @@ import { useControlPanelStore } from "../../../stores/controlPanelStore";
import { blockDragPreviewStyle } from "./style";
import { useReactFlow } from "@xyflow/react";
import { useNodeStore } from "../../../stores/nodeStore";
import { SpecialBlockID } from "@/lib/autogpt-server-api";
import { BlockUIType, SpecialBlockID } from "@/lib/autogpt-server-api";
import {
MCPToolDialog,
type MCPToolDialogResult,
@@ -41,7 +41,7 @@ export const Block: BlockComponent = ({
const { addBlock } = useNodeStore();
const [mcpDialogOpen, setMcpDialogOpen] = useState(false);
const isMCPBlock = blockData.id === SpecialBlockID.MCP_TOOL;
const isMCPBlock = blockData.uiType === BlockUIType.MCP_TOOL;
const addBlockAndCenter = useCallback(
(block: BlockInfo, hardcodedValues?: Record<string, any>) => {

View File

@@ -212,7 +212,7 @@ export function BlocksControl({
if (block.notAvailable) return;
// For MCP blocks, open the configuration dialog instead of placing directly
if (block.id === SpecialBlockID.MCP_TOOL) {
if (block.uiType === BlockUIType.MCP_TOOL) {
setMcpDialogOpen(true);
return;
}
@@ -349,19 +349,19 @@ export function BlocksControl({
className={`m-2 my-4 flex h-20 shadow-none dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:hover:bg-slate-700 ${
block.notAvailable
? "cursor-not-allowed opacity-50"
: block.id === SpecialBlockID.MCP_TOOL
: block.uiType === BlockUIType.MCP_TOOL
? "cursor-pointer hover:shadow-lg"
: "cursor-move hover:shadow-lg"
}`}
data-id={`block-card-${block.id}`}
draggable={
!block.notAvailable &&
block.id !== SpecialBlockID.MCP_TOOL
block.uiType !== BlockUIType.MCP_TOOL
}
onDragStart={(e) => {
if (
block.notAvailable ||
block.id === SpecialBlockID.MCP_TOOL
block.uiType === BlockUIType.MCP_TOOL
)
return;
e.dataTransfer.effectAllowed = "copy";

View File

@@ -21,7 +21,6 @@ import {
GraphInputSchema,
GraphOutputSchema,
NodeExecutionResult,
SpecialBlockID,
} from "@/lib/autogpt-server-api";
import {
beautifyString,
@@ -218,7 +217,7 @@ export const CustomNode = React.memo(
// MCP Tool block: display the selected tool's dynamic schema
const isMCPWithTool =
data.block_id === SpecialBlockID.MCP_TOOL &&
data.uiType === BlockUIType.MCP_TOOL &&
!!data.hardcodedValues?.tool_input_schema?.properties;
if (isMCPWithTool) {

View File

@@ -753,7 +753,7 @@ const FlowEditor: React.FC<{
isOutputStatic: nodeSchema.staticOutput,
uiType: nodeSchema.uiType,
// Set customized_name at creation so it persists through save/load
...(blockID === SpecialBlockID.MCP_TOOL && {
...(nodeSchema.uiType === BlockUIType.MCP_TOOL && {
metadata: {
credentials_optional: true,
...(finalHardcodedValues.selected_tool && {

View File

@@ -9,4 +9,5 @@ export enum BlockUIType {
AGENT = "Agent",
AI = "AI",
AYRSHARE = "Ayrshare",
MCP_TOOL = "MCP Tool",
}

View File

@@ -749,6 +749,7 @@ export enum BlockUIType {
AGENT = "Agent",
AI = "AI",
AYRSHARE = "Ayrshare",
MCP_TOOL = "MCP Tool",
}
export enum SpecialBlockID {