Skip to main content
Glama

Civil 3D MCP Server — Code Execution Architecture

An MCP server that enables AI assistants to write and execute C# code directly inside Autodesk Civil 3D. Instead of fixed tools, the AI generates code that runs with full API access.

Architecture

┌─────────────────┐     stdio      ┌──────────────────┐     TCP/JSON-RPC    ┌──────────────────┐
│   AI Assistant   │ ◄────────────► │  MCP Server (TS) │ ◄──────────────────► │  Civil 3D Plugin │
│ (Claude, Cline)  │               │   3 meta-tools    │     port 8080       │  Roslyn Engine   │
└─────────────────┘               └──────────────────┘                      └──────────────────┘
                                         │                                         │
                                    Skills Library                           C# Code Execution
                                   (.skill.md files)                      (full Civil 3D API)

Related MCP server: revit-mcp

3 Meta-Tools

Tool

Purpose

Safety

civil3d_execute

Execute C# code with write access (transaction committed)

⚠️ Modifies drawing

civil3d_query

Execute C# code read-only (no commit)

✅ No side effects

civil3d_skills

Browse/search/read code skill templates

✅ Metadata only

How It Works

  1. AI reads a skill → Gets a documented C# code template

  2. AI adapts the code → Fills in parameters, combines patterns

  3. AI sends code → Via civil3d_execute or civil3d_query

  4. Roslyn compiles + runs → Inside Civil 3D with full API access

  5. Results return as JSON → Back to the AI

Example Interaction

User: "What surfaces are in my drawing?"

AI: Uses civil3d_query with:
  var surfaces = new List<object>();
  foreach (ObjectId id in CivilDoc.GetSurfaceIds()) {
    var s = Transaction.GetObject(id, OpenMode.ForRead) as TinSurface;
    surfaces.Add(new { s.Name, s.Layer });
  }
  return surfaces;

Result: [{ "Name": "EG", "Layer": "C-TOPO-EG" }, ...]

Skills Library

Skills are documented C# code templates in skills/:

skills/
├── surfaces/           # Surface operations
├── alignments/         # Alignment + station/offset
├── points/             # COGO points
├── geometry/           # Lines, polylines, text
├── drawing/            # Drawing info
└── workflows/          # Complex multi-object operations

Script Globals

Code executed via civil3d_execute or civil3d_query has access to:

Global

Type

Description

Document

Document

Active AutoCAD document

CivilDoc

CivilDocument

Active Civil 3D document

Database

Database

Document database

Transaction

Transaction

Active transaction

Editor

Editor

Document editor

All Civil 3D namespaces are auto-imported.

Setup

1. Build MCP Server

npm install && npm run build

2. Build Plugin

# Copy DLLs from Civil 3D to C_References/ (see C_References/README.md)
cd plugin/Civil3dMcpPlugin
dotnet build

3. Load in Civil 3D

NETLOAD → select Civil3dMcpPlugin.dll
C3DMCPSTATUS → verify running

4. Configure AI

{
  "mcpServers": {
    "civil3d": {
      "command": "node",
      "args": ["/path/to/civil3d-mcp/build/index.js"]
    }
  }
}

Environment Variables

Variable

Default

Description

CIVIL3D_HOST

localhost

Plugin host

CIVIL3D_PORT

8080

Plugin port

CIVIL3D_COMMAND_TIMEOUT

120000

Execution timeout (ms)

LOG_LEVEL

info

Log level

Security

The Roslyn sandbox blocks:

  • Process execution (Process.Start)

  • File deletion (File.Delete)

  • Network requests (HttpClient, Sockets)

  • Registry access

  • Dynamic assembly loading

All Civil 3D API operations are allowed.

License

MIT

Available Tools

3 tools
civil3d_executeA

Execute C# code in Civil 3D with write access. The code runs inside a committed transaction. Available globals: Document, CivilDoc, Database, Transaction, Editor. All Civil 3D namespaces are auto-imported. Return a value to get results back as JSON. Use this for operations that MODIFY the drawing (create, edit, delete objects).

ParametersJSON Schema
NameRequiredDescriptionDefault
codeYesC# code to execute. Has access to Document, CivilDoc, Database, Transaction, Editor. Example: var id = TinSurface.Create(Database, "MySurface"); return new { success = true };
descriptionNoBrief description of what this code does (for logging/audit trail).

TDQS

A4.2/5.0
Behavior4/5

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

No annotations, but description covers transaction context, available globals, auto-imports, and JSON return. Good disclosure of execution environment, though lacks error handling details.

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?

Four concise sentences, each providing unique value. Front-loaded with purpose. No wasted words.

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?

Comprehensive for a code execution tool: covers purpose, transaction, globals, return format, and modification scope. Absence of output schema mitigated by description of JSON return.

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 covers both parameters fully (100% coverage). Description reinforces code purpose with example but adds limited new semantic value beyond schema descriptions.

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?

Clearly states verb 'Execute' and resource 'C# code in Civil 3D'. Distinguishes from siblings by emphasizing write access and modification, contrasting with query tool.

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

Usage Guidelines4/5

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

Explicitly states when to use: 'for operations that MODIFY the drawing'. Implies not for read-only, but could be more explicit about not using for queries.

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

civil3d_queryA

Execute C# code in Civil 3D in READ-ONLY mode (no changes saved). Available globals: Document, CivilDoc, Database, Transaction, Editor. All Civil 3D namespaces are auto-imported. Return a value to get results as JSON. Use this for querying data: listing objects, getting properties, analyzing surfaces, etc.

ParametersJSON Schema
NameRequiredDescriptionDefault
codeYesC# code to query data. Has access to Document, CivilDoc, Database, Transaction, Editor. Example: var surfaces = new List<object>(); foreach (ObjectId id in CivilDoc.GetSurfaceIds()) { var s = Transaction.GetObject(id, OpenMode.ForRead) as TinSurface; surfaces.Add(new { s.Name, s.Layer }); } return surfaces;

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations, the description carries the full burden. It clearly states READ-ONLY mode and lists available globals (Document, CivilDoc, Database, Transaction, Editor) and notes that all Civil 3D namespaces are auto-imported. It also explains how to return results as JSON. However, it does not mention error handling, performance implications, or any limitations.

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 concise with three sentences, each serving a distinct purpose: stating the read-only mode, listing globals, and providing usage guidance. There is no redundant or unnecessary information.

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

Completeness5/5

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

Given the tool's complexity (code execution) and single parameter, the description covers all needed aspects: read-only guarantee, available globals, auto-imported namespaces, and how to return results. No output schema exists, but the description explains the JSON return format. It is complete for safe and correct usage.

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

Parameters4/5

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

There is only one parameter 'code' with a schema description that includes an example. The description adds value by specifying the available globals and auto-imported namespaces, which are not in the schema. Since schema coverage is 100%, baseline is 3, but the added context justifies a 4.

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 tool executes C# code in Civil 3D in READ-ONLY mode, with a specific verb and resource. It distinguishes from siblings by emphasizing read-only querying vs. execution, and the sibling names (civil3d_execute, civil3d_skills) further clarify the differentiation.

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

Usage Guidelines4/5

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

The description explicitly says 'Use this for querying data: listing objects, getting properties, analyzing surfaces, etc.' This provides clear when-to-use guidance. It does not explicitly state when not to use it, but the READ-ONLY mode and sibling names imply it is not for modifications. A small gap in not naming the alternative directly.

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

civil3d_skillsA

Browse and read Civil 3D code skills (documented C# code templates). Use 'list' to see available skills, 'search' to find by keyword, 'get' to read the full skill with code template. Skills are pre-built C# patterns you can adapt and execute via civil3d_execute or civil3d_query.

ParametersJSON Schema
NameRequiredDescriptionDefault
actionYeslist = show all skills, search = find by keyword, get = read full skill
categoryNoFilter by category (surfaces, alignments, points, etc.)
queryNoSearch query for 'search' action
skillNameNoSkill name for 'get' action

TDQS

A4.2/5.0
Behavior3/5

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

No annotations provided, so description is the sole source. It explains the three actions and their purposes, but does not disclose additional behavioral traits such as error handling, pagination, or authentication needs. Adequate but not detailed.

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?

Two sentences with clear front-loading of purpose and actions. No filler or redundancy. Every sentence adds value.

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 simple browse tool with 4 parameters and no output schema, the description covers the essential actions and their usage. It could optionally clarify category usage with list, but overall it is complete enough.

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 coverage is 100% with individual parameter descriptions. The description adds context (e.g., list = show all skills) but does not significantly augment the schema's own descriptions. Baseline 3 is appropriate.

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?

Description clearly states 'Browse and read Civil 3D code skills' and lists three specific actions (list, search, get) with brief explanations. Distinguishes from siblings by focusing on browsing/reading versus execution/query.

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?

Explicitly mentions that skills are 'pre-built C# patterns you can adapt and execute via civil3d_execute or civil3d_query', providing clear when-to-use vs alternatives.

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

TDQS

A4.4/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: civil3d_execute for modifying drawings, civil3d_query for read-only queries, and civil3d_skills for browsing code templates. There is no overlap or ambiguity.

Naming Consistency4/5

All tools follow a consistent 'civil3d_' prefix pattern with an action word. Two use verbs (execute, query) and one uses a noun (skills), which is a minor inconsistency, but the naming remains predictable and clear.

Tool Count5/5

With 3 tools, the server is well-scoped for its purpose of executing C# code in Civil 3D. Each tool serves a necessary role: write access, read access, and skill templates. No extraneous tools.

Completeness4/5

The tool set covers the core operations for the meta-domain of code execution (read, write, and reference templates). However, it relies on the agent to write code for specific Civil 3D operations, so domain-specific completeness is limited but acceptable for the stated purpose.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to interact with Autodesk Construction Cloud (ACC) projects through natural language, allowing users to query project data, manage issues and RFIs, browse files, and automate construction workflows directly from their development environment.
    1
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Enables AI assistants to interact with Autodesk Revit to query project data, manage elements, and execute generated code via the Model Context Protocol. It provides full compatibility with GitHub Copilot and Claude to automate BIM modeling workflows.
    13
    91
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Enables AI assistants to interact with Autodesk Civil 3D through natural language, supporting tools for surfaces, alignments, profiles, corridors, pipe networks, COGO points, and AutoCAD geometry.
    9
    2
    MIT

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/barbosaihan/civil3d-mcp'

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