Skip to main content
Glama
awwaiid

MCP Server for Alloy Modeling Language

by awwaiid

execute_alloy

Execute Alloy modeling language code to perform formal verification and software modeling, returning structured JSON results for analysis.

Instructions

Execute Alloy modeling language code and return structured JSON results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe Alloy modeling language code to execute

Implementation Reference

  • Handler function that executes the provided Alloy code using alloy.eval(code), processes the result (success or error), and returns structured content with JSON for success cases and error messages.
    async ({ code }) => { try { const result = alloy.eval(code); // Type guard: check if result is an error if ('error' in result) { return { content: [ { type: "text", text: `Error executing Alloy code: ${result.error}` } ], isError: true }; } // TypeScript now knows result is AlloySuccessResult return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error executing Alloy code: ${errorMessage}` } ], isError: true }; } } );
  • Zod schema defining the input parameter 'code' for the execute_alloy tool.
    { code: z.string().describe("The Alloy modeling language code to execute"), },
  • src/index.ts:16-60 (registration)
    Registration of the execute_alloy tool using server.tool(), including name, description, input schema, and inline handler function.
    "execute_alloy", "Execute Alloy modeling language code and return structured JSON results", { code: z.string().describe("The Alloy modeling language code to execute"), }, async ({ code }) => { try { const result = alloy.eval(code); // Type guard: check if result is an error if ('error' in result) { return { content: [ { type: "text", text: `Error executing Alloy code: ${result.error}` } ], isError: true }; } // TypeScript now knows result is AlloySuccessResult return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error executing Alloy code: ${errorMessage}` } ], isError: true }; } } );
  • Type definitions for the 'alloy-lang' module, defining interfaces for Alloy results used in the handler for type guarding and processing.
    declare module 'alloy-lang' { export interface AlloyInstance { messages: unknown[]; skolems: Record<string, unknown>; state: number; values: Record<string, unknown>; } export interface AlloySuccessResult { duration: number; incremental: boolean; instances: AlloyInstance[]; localtime: string; loopstate: number; sigs: Record<string, unknown>; timezone: string; utctime: number; } export interface AlloyErrorResult { error: string; } export type AlloyResult = AlloySuccessResult | AlloyErrorResult; export function evalRaw(alloyProgram: string): string; export function eval(alloyProgram: string): AlloyResult; const alloy: { evalRaw: typeof evalRaw; eval: typeof eval; }; export default alloy; }

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/awwaiid/mcp-server-alloy'

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