Skip to main content
Glama

roslyn:validate_code

Validate C# code compilation without writing to disk. Check AI-generated code for errors before applying changes using Roslyn compiler analysis.

Instructions

Check if code would compile without writing to disk. Use to validate generated code before applying.

USAGE: validate_code(code="public void Foo() {}", contextFilePath="path/to/file.cs") to check with existing usings. OUTPUT: compiles (bool), errors list with line numbers. Essential before inserting AI-generated code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesC# code to validate
contextFilePathNoOptional: file to use for context (usings, namespace)
standaloneNoIf true, treat code as complete file (default: false)
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: the tool performs compilation checks without disk writes, returns a boolean 'compiles' status and error list with line numbers, and is designed for validation purposes. It doesn't mention performance characteristics like rate limits or authentication needs, but covers the core operational behavior well.

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

Conciseness5/5

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

The description is efficiently structured with three focused sentences: purpose statement, usage example, and output explanation. Each sentence adds distinct value without redundancy. The information is front-loaded with the core purpose, making it easy for an agent to quickly understand the tool's function.

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

Completeness4/5

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

For a validation tool with no annotations and no output schema, the description provides good coverage: it explains what the tool does, when to use it, what parameters mean (through the example), and what output to expect. The main gap is the lack of a formal output schema, but the description compensates by describing the return structure. Given the tool's moderate complexity, this is nearly complete.

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?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds minimal parameter semantics beyond the schema, only mentioning the 'contextFilePath' parameter in the usage example to illustrate its purpose. This meets the baseline expectation when schema coverage is complete.

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

Purpose5/5

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

The description clearly states the specific action ('Check if code would compile without writing to disk') and resource ('code'), distinguishing it from siblings like 'analyze_method' or 'get_diagnostics' by focusing on compilation validation rather than analysis or diagnostics retrieval. It explicitly mentions validating AI-generated code, which sets it apart from other code manipulation tools.

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

Usage Guidelines5/5

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

The description provides explicit usage guidance: 'Use to validate generated code before applying' and 'Essential before inserting AI-generated code.' It clearly indicates when to use this tool (for pre-application validation) versus when not to (after code is already applied or for non-validation purposes), though it doesn't name specific alternative tools from the sibling list.

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/pzalutski-pixel/sharplens-mcp'

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