Skip to main content
Glama
jim-coyne

Hyperfabric MCP Server

vrfsGetFabricVrf

Retrieve specific Virtual Routing and Forwarding (VRF) configuration details from Hyperfabric network fabrics using fabric and VRF identifiers.

Instructions

Get a specific VRF.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fabricIdYesThe fabric id or name.
vrfIdYesThe VRF id or name.
candidateNoThe candidate configuration name. If not set the default candidate configuration values are returned.
includeMetadataNoInclude object metadata in the response.

Implementation Reference

  • This is the core handler function that executes ANY tool call, including 'vrfsGetFabricVrf'. It matches the tool name to an OpenAPI path/method/operationId, constructs the API request (path params, query, body), calls the Hyperfabric REST API via axios, and returns the JSON response.
    private async executeApiCall(toolName: string, args: any): Promise<any> {
      // Validate inputs for port configuration tools to prevent misuse
      if (toolName === 'nodesSetPorts' || toolName === 'nodesUpdatePort') {
        // Ensure no executable content or shell commands in arguments
        const argsStr = JSON.stringify(args);
        if (/(\$\(|`|eval|exec|system|spawn|child_process)/.test(argsStr)) {
          throw new Error('Security: Invalid arguments detected. Port configuration tools only accept network settings (speed, MTU, VLAN, etc.)');
        }
      }
      
      // Extract the original method and path from the tool name
      // This is a simplified approach - in a production system you'd want a more robust mapping
      
      if (!this.openApiSpec?.paths) {
        throw new Error("OpenAPI spec not loaded");
      }
    
      // Find the corresponding operation
      let foundOperation: { method: string; path: string; operation: OpenAPIOperation } | null = null;
      
      for (const [pathKey, pathItem] of Object.entries(this.openApiSpec.paths)) {
        for (const [method, operation] of Object.entries(pathItem)) {
          if (typeof operation !== 'object' || !operation) continue;
          
          const op = operation as OpenAPIOperation;
          const expectedToolName = this.generateToolName(method, pathKey, op);
          
          if (expectedToolName === toolName) {
            foundOperation = { method, path: pathKey, operation: op };
            break;
          }
        }
        if (foundOperation) break;
      }
    
      if (!foundOperation) {
        throw new Error(`No operation found for tool: ${toolName}`);
      }
    
      // Build the URL by replacing path parameters
      let url = foundOperation.path;
      const queryParams: Record<string, string> = {};
      
      // Handle path and query parameters
      if (foundOperation.operation.parameters) {
        for (const param of foundOperation.operation.parameters) {
          const value = args[param.name];
          if (value !== undefined) {
            if (param.in === 'path') {
              url = url.replace(`{${param.name}}`, encodeURIComponent(value));
            } else if (param.in === 'query') {
              queryParams[param.name] = value;
            }
          }
        }
      }
    
      // Prepare the request
      const requestConfig: any = {
        method: foundOperation.method.toUpperCase(),
        url,
        params: queryParams,
      };
    
      // Handle request body for POST/PUT/PATCH
      if (['post', 'put', 'patch'].includes(foundOperation.method.toLowerCase())) {
        // Check if args has a requestBody property (legacy format)
        if (args.requestBody) {
          requestConfig.data = args.requestBody;
        } else {
          // Build request body from exposed properties
          // This handles cases where schema properties are exposed directly (e.g., fabrics, nodes, etc.)
          const requestBody: Record<string, any> = {};
          const pathItem = this.openApiSpec?.paths?.[foundOperation.path];
          const operation = (pathItem as any)?.[foundOperation.method];
          
          if (operation?.requestBody) {
            const requestBodyDef = this.resolveSchemaRef(operation.requestBody);
            const schema = this.deepResolveSchema(requestBodyDef.content?.['application/json']?.schema);
            
            // Collect all properties that are part of the request body schema
            if (schema?.properties) {
              for (const propName of Object.keys(schema.properties)) {
                if (args.hasOwnProperty(propName)) {
                  requestBody[propName] = args[propName];
                }
              }
            }
          }
          
          if (Object.keys(requestBody).length > 0) {
            requestConfig.data = requestBody;
          }
        }
      }
    
      logger.debug(`Making API call: ${requestConfig.method} ${url}`);
      
      try {
        const response = await this.httpClient.request(requestConfig);
        return {
          status: response.status,
          statusText: response.statusText,
          data: response.data
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new Error(`API call failed: ${error.response?.status} ${error.response?.statusText} - ${JSON.stringify(error.response?.data)}`);
        }
        throw error;
      }
    }
  • src/main.ts:134-158 (registration)
    Generates all Tool definitions from OpenAPI spec loaded from hf_spec_modified.json. Uses operation.operationId as tool name if present (expected to include 'vrfsGetFabricVrf'), or falls back to method_path. Pushes to this.tools array returned by ListTools.
    private generateTools(): void {
      if (!this.openApiSpec?.paths) {
        logger.error("No paths found in OpenAPI spec");
        return;
      }
    
      this.tools = [];
    
      for (const [pathKey, pathItem] of Object.entries(this.openApiSpec.paths)) {
        for (const [method, operation] of Object.entries(pathItem)) {
          if (typeof operation !== 'object' || !operation) continue;
          
          const op = operation as OpenAPIOperation;
          const toolName = this.generateToolName(method, pathKey, op);
          const tool = this.createToolFromOperation(toolName, method, pathKey, op);
          
          if (tool) {
            this.tools.push(tool);
            logger.debug(`Generated tool: ${toolName}`);
          }
        }
      }
    
      logger.info(`Generated ${this.tools.length} tools from OpenAPI spec`);
    }
  • Dynamically generates the inputSchema (JSON Schema) for each tool based on OpenAPI operation parameters (path/query) and requestBody properties. Handles refs and deep resolution for validation/type info of 'vrfsGetFabricVrf' inputs.
    private createToolFromOperation(
      name: string,
      method: string,
      path: string,
      operation: OpenAPIOperation
    ): Tool | null {
      let description = operation.summary || operation.description || `${method.toUpperCase()} ${path}`;
      
      // Add security context for network port configuration operations
      if (name === 'nodesSetPorts' || name === 'nodesUpdatePort') {
        description += '\n\n[SAFE OPERATION] This tool configures network fabric port settings (speed, MTU, VLAN, etc.) via REST API. It does NOT execute code or commands on the system.';
      }
      
      // Enhance description for create/update operations
      if (['post', 'put', 'patch'].includes(method.toLowerCase())) {
        if (method.toLowerCase() === 'post') {
          description += '\n\nTo use this tool, pass the required fields as direct arguments (e.g., fabrics=[{name:"my-fabric", description:"...", ...}])';
        } else if (method.toLowerCase() === 'put') {
          description += '\n\nTo use this tool, pass the resource ID and the fields to update as arguments';
        } else if (method.toLowerCase() === 'patch') {
          description += '\n\nTo use this tool, pass the resource ID and the fields to patch as arguments';
        }
      }
      
      const properties: Record<string, any> = {};
      const required: string[] = [];
    
      // Process parameters
      if (operation.parameters) {
        for (const param of operation.parameters) {
          if (param.in === 'path' || param.in === 'query') {
            properties[param.name] = {
              type: param.schema?.type || 'string',
              description: param.description || ''
            };
            
            if (param.required) {
              required.push(param.name);
            }
          }
        }
      }
    
      // Process request body for POST/PUT/PATCH requests
      if (operation.requestBody && ['post', 'put', 'patch'].includes(method.toLowerCase())) {
        // Resolve the requestBody reference if it exists
        const requestBody = this.resolveSchemaRef(operation.requestBody);
        const content = requestBody.content;
        
        if (content?.['application/json']?.schema) {
          let schema = content['application/json'].schema;
          // Deeply resolve schema references
          schema = this.deepResolveSchema(schema);
          
          if (schema.properties) {
            // Expose the request body properties directly
            for (const [propName, propSchema] of Object.entries(schema.properties)) {
              const propDef = propSchema as any;
              properties[propName] = this.deepResolveSchema(propDef, 0);
              
              if (schema.required?.includes(propName)) {
                required.push(propName);
              }
            }
          }
        }
      }
    
      return {
        name,
        description,
        inputSchema: {
          type: 'object',
          properties,
          required
        }
      };
    }
  • src/main.ts:293-295 (registration)
    Registers the MCP ListTools handler to return the full list of generated tools, including 'vrfsGetFabricVrf'.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools: this.tools };
    });
  • Registers the MCP CallToolRequestSchema handler, which dispatches to executeApiCall for the specific tool execution.
      this.server.setRequestHandler(CallToolRequestSchema, async (request: any) => {
        const { name, arguments: args } = request.params;
        
        logger.info(`Calling tool: ${name}`);
        logger.debug(`Tool arguments: ${JSON.stringify(args, null, 2)}`);
        
        try {
          // Find the tool definition
          const tool = this.tools.find(t => t.name === name);
          if (!tool) {
            throw new Error(`Tool ${name} not found`);
          }
    
          // Execute the API call
          const result = await this.executeApiCall(name, args);
          
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(result, null, 2)
              }
            ]
          };
        } catch (error) {
          logger.error(`Error executing tool ${name}:`, error);
          
          return {
            content: [
              {
                type: "text",
                text: `Error: ${error instanceof Error ? error.message : String(error)}`
              }
            ],
            isError: true
          };
        }
      });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the action without behavioral details. It does not disclose if this is a read-only operation, requires authentication, has side effects, or how errors are handled. For a tool with parameters and no annotations, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, straightforward sentence with no wasted words, making it easy to parse. However, it could be more front-loaded with key details (e.g., 'Retrieve configuration for a VRF') to improve clarity without sacrificing brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (4 parameters, no annotations, no output schema), the description is incomplete. It does not explain what is returned (e.g., VRF details, error formats) or behavioral aspects like idempotency or permissions. For a tool that likely returns structured data, this leaves critical gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting all four parameters. The description adds no additional meaning beyond the schema, such as explaining parameter interactions or examples. Baseline 3 is appropriate as the schema does the heavy lifting, but no extra value is provided.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the action ('Get') and target ('a specific VRF'), which clarifies the basic purpose. However, it lacks specificity about what 'get' entails (e.g., retrieve configuration, status, or metadata) and does not differentiate from sibling tools like 'vrfsGetFabricVrfs' (plural) or 'vrfsUpdateFabricVrf', leaving the scope ambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description does not mention prerequisites, context (e.g., after creation or update), or comparisons to siblings such as 'vrfsGetFabricVrfs' for listing multiple VRFs, leaving usage decisions unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jim-coyne/hyperfabric_MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server