Civil 3D MCP Server
Civil 3D MCP Server — Dynamic Roslyn Fork
AI 어시스턴트가 Autodesk Civil 3D 내부에서 직접 C# 코드를 작성하고 실행할 수 있게 해주는 MCP 서버입니다. 대규모 고정 도구 세트 대신, AI가 Civil 3D API 액세스 권한으로 실행되는 작업별 코드를 생성합니다.
프로젝트 범위 및 계보
이 포크는 동적 Roslyn/C# 실행 모델과 의도적으로 작게 유지된 세 가지 MCP 도구의 공개 표면을 유지합니다. 현재 호환성 기준선은 Autodesk Civil 3D 2025이며, 로컬 작업은 안정성, 안전성, 측정 가능한 효율성 및 재사용 가능한 Civil 3D 스킬에 중점을 둡니다. 다른 Civil 3D 버전은 별도로 검증된 호환성 작업을 통해 나중에 추가할 수 있습니다.
이 프로젝트는 barbosaihan/civil3d-mcp에서 파생되었습니다. SantosSjba/mcp-to-c3d는 선별된 테스트 기반 아이디어를 위해 평가되었으며, Sacred-G/Civil3D-mcp는 아키텍처 참고 자료로만 사용되었습니다. 자세한 출처 표기 및 라이선스 경계는 PROVENANCE.md를 참조하세요.
이 독립 프로젝트는 Autodesk와 제휴하지 않으며 Autodesk의 보증을 받지 않습니다. Autodesk 어셈블리 및 기타 독점 Civil 3D 파일은 포함되지 않습니다.
Related MCP server: Civil 3D MCP Server
아키텍처
┌─────────────────┐ 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)3가지 메타 도구
도구 | 용도 | 안전성 |
| 쓰기 액세스 권한으로 C# 코드 실행; 커밋 후 선택적 저장 | ⚠️ 도면 수정 |
| C# 코드를 읽기 전용으로 실행(커밋 없음) | ✅ 부작용 없음 |
| 코드 스킬 템플릿 탐색/검색/읽기; | ✅ 메타데이터 전용 |
작동 방식
AI가 스킬을 읽습니다 → 문서화된 C# 코드 템플릿을 얻습니다
AI가 코드를 조정합니다 → 매개변수를 채우고 패턴을 결합합니다
AI가 코드를 전송합니다 →
civil3d_execute또는civil3d_query를 통해Roslyn이 컴파일하고 실행합니다 → 완전한 API 액세스 권한으로 Civil 3D 내부에서
결과가 JSON으로 반환됩니다 → AI에게 다시 전달됩니다
예시 상호작용
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" }, ...]스킬 라이브러리
civil3d_skills는 또한 이미 로드되어 허용 목록에 포함된 Civil 3D 호스트 어셈블리의 공개 형식 및 멤버 이름/시그니처에 대한 제한적이고 읽기 전용인 검색을 수행하는 action: "api_lookup"을 지원합니다. api_lookup은 어셈블리를 로드하지 않으며, C# 코드를 실행하거나 활성 도면에 접근하지 않습니다. 쿼리와 함께 선택적으로 어셈블리, 네임스페이스 접두사, 결과 제한을 제공하세요.
스킬은 skills/에 있는 문서화된 C# 코드 템플릿입니다:
skills/
├── surfaces/ # Surface operations
├── alignments/ # Alignment + station/offset
├── points/ # COGO points
├── geometry/ # Lines, polylines, text
├── drawing/ # Drawing info
└── workflows/ # Complex multi-object operations스크립트 전역 변수
civil3d_execute 또는 civil3d_query를 통해 실행되는 코드는 다음 항목에 접근할 수 있습니다:
전역 변수 | 유형 | 설명 |
|
| 활성 AutoCAD 문서 |
|
| 활성 Civil 3D 문서 |
|
| 문서 데이터베이스 |
|
| 활성 트랜잭션 |
|
| 문서 편집기 |
모든 Civil 3D 네임스페이스는 자동으로 가져오기(import)됩니다.
civil3d_execute 트랜잭션을 커밋하면 열린 도면이 변경되지만 그 자체로 DWG 파일을 디스크에 쓰지는 않습니다. 완료된 변경 사항도 저장해야 하는 경우 saveDrawing: true를 설정하세요. 플러그인은 스크립트 트랜잭션과 문서 잠금이 닫힌 후에만 저장합니다. 스크립트는 Database.SaveAs를 호출하거나 QSAVE를 직접 큐에 넣으면 안 됩니다. 저장 요청은 별도의 기본 10분 타임아웃을 사용하며 자동으로 재시도되지 않습니다.
설정
1. MCP 서버 빌드
npm install && npm run build2. 플러그인 빌드
# Copy DLLs from Civil 3D to C_References/ (see C_References/README.md)
cd plugin/Civil3dMcpPlugin
dotnet build3. Civil 3D에서 로드
NETLOAD → select Civil3dMcpPlugin.dll
C3DMCPSTATUS → verify running4. AI 구성
{
"mcpServers": {
"civil3d": {
"command": "node",
"args": ["/path/to/civil3d-mcp/build/index.js"]
}
}
}환경 변수
변수 | 기본값 | 설명 |
|
| 플러그인 호스트 |
|
| 플러그인 포트 |
|
| 실행 타임아웃(ms) |
|
|
|
|
| 로그 수준 |
벤치마킹
2A 단계의 호스트 독립적 레코더, 2A.1 단계의 옵트인 내부 실시간 추적 계약, 그리고 2A.2 단계의 읽기 전용 실시간 러너는 benchmark/README.md에 문서화되어 있습니다. 어떤 것도 MCP 도구, 큐, 재시도를 추가하지 않습니다. 2A.2 러너는 명시적으로 시작될 때만 고정된 읽기 전용 쿼리를 호출할 수 있습니다.
구조화된 오류(2B.1 단계)
civil3d_query와 civil3d_execute는 기존의 텍스트 오류 내용과 isError: true를 유지하면서, civil3d-mcp-error/v1 스키마의 structuredContent도 함께 반환합니다. 안정적인 오류 필드는 code, category, message, source, outcome, retryable입니다. 명령 타임아웃 또는 전송 후 연결 끊김은 outcome: "unknown" 및 retryable: false를 갖습니다. 서버는 이를 자동으로 재시도하지 않습니다. 성공 응답과 세 가지 도구의 공개 표면은 변경되지 않습니다.
비공개 TCP 프레이밍(2C.1 단계)
각 localhost TCP 연결은 하나의 UTF-8 JSON-RPC 요청과 하나의 응답을 전달합니다. 각 JSON 본문 뒤에는 LF가 오며, LF를 제외한 UTF-8 바이트 기준으로 8 MiB로 제한됩니다. Node 클라이언트는 완전한 JSON 본문 뒤에 정상적인 연결 종료가 이어지는 경우, 이전 플러그인의 프레이밍되지 않은 응답도 계속 수락합니다. 크기가 초과된 요청은 쓰기 전에 거부됩니다. 크기가 초과되거나 잘못된 형식의 응답 및 중단된 연결은 재시도 불가능한 구조화된 전송 오류를 생성합니다. 실행이 완료되었지만 플러그인이 크기가 초과된 결과를 반환할 수 없는 경우, 보고되는 outcome은 unknown입니다.
작업 감사 로깅 및 쓰기 멱등성(2I.1 / 2I.2 단계)
기본 info 로그 수준에서, 수락된 각 civil3d_query 및 civil3d_execute 작업은 하나의 크기가 제한된 stderr 감사 이벤트를 출력합니다. 이 이벤트에는 새로운 불투명 작업 ID, 도구 이름, C# 소스의 SHA-256 및 UTF-8 바이트 길이, 성공/오류 상태, 경과 시간(밀리초)이 포함됩니다. 오류는 안정적인 code/category/source/outcome 필드만 추가합니다. 감사 이벤트에는 호출자 코드, 설명, 도면 식별자, 결과 또는 오류 메시지가 절대 포함되지 않습니다.
civil3d_execute는 또한 선택적 불투명 idempotencyKey(1–128자의 ASCII 문자, 숫자, ., _, :, -)를 허용합니다. 하나의 플러그인 세션에서 이 키는 UTF-8 C# SHA-256, 정규화된 expectedDrawing 식별자 및 saveDrawing 선택에 바인딩됩니다. 중복 키는 진행 중, 충돌 또는 이미 커밋됨으로 거부됩니다. 커밋된 항목은 결과를 보유하지 않으므로 호출자는 읽기 전용 쿼리로 조정해야 합니다. 저장 실패는 메모리 내 쓰기 커밋 이후에 발생하므로, 우발적인 중복 수정을 방지하기 위해 해당 키는 완료(completed) 상태로 유지됩니다. 세션은 완료된 키를 최대 256개까지 유지하며, 가장 오래된 키를 결정적으로 제거합니다. 이 기능은 지속성, 자동 재시도, 정확히 한 번(exactly-once) 의미론 중 어느 것도 추가하지 않습니다.
보안
Roslyn 샌드박스는 다음을 차단합니다:
프로세스 실행(
Process.Start)파일 삭제(
File.Delete)네트워크 요청(
HttpClient,Sockets)레지스트리 액세스
동적 어셈블리 로드
모든 Civil 3D API 작업은 허용됩니다.
이 정규식 샌드박스는 심층 방어(defense in depth) 수단이지 신뢰 경계가 아닙니다. 두 코드 도구 모두 변경 가능한 Civil 3D 및 AutoCAD API 객체를 받습니다. civil3d_query는 호스트의 트랜잭션 커밋을 건너뛰지만, 임의의 동적 C# 코드에 부작용이 없음을 보장할 수는 없습니다. 신뢰할 수 있고 승인을 거친 코드만 실행하세요. 루프백 TCP는 원격 네트워크 액세스를 차단하지만 다른 로컬 프로세스를 인증하지는 않습니다.
라이선스
MIT
Available Tools
3 toolscivil3d_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). expectedDrawing must come from a prior read-only identity query. To persist the drawing file, set saveDrawing=true; do not call Database.SaveAs or queue QSAVE from the C# code.
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | C# code to execute. Has access to Document, CivilDoc, Database, Transaction, Editor. Example: var id = TinSurface.Create(Database, "MySurface"); return new { success = true }; | |
| description | No | Optional human-readable summary; excluded from operation audit logs. | |
| saveDrawing | No | When true, save the currently named DWG after the write transaction commits and wait for completion. Use this instead of Database.SaveAs or Document.SendStringToExecute("QSAVE") in code. An unsaved drawing must first be named in Civil 3D. | |
| idempotencyKey | No | Optional opaque session key. Reuse it only to manually reconcile an uncertain outcome; use a new key for an intentional new write. | |
| expectedDrawing | Yes | Expected active drawing identity checked immediately before Civil API access. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden and does well: it notes the committed transaction, available globals, JSON return, drawing identity check, and save workflow. It does not mention exception handling or failure rollback, but that is a minor gap for a code-execution tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact and front-loaded with the core purpose, then elaborates on key parameters and constraints. It is not overly verbose, though bullet formatting could improve scannability; still, every sentence earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a complex code-execution tool with no output schema, the description explains available globals, return format, drawing identity requirements, save behavior, and sibling distinction. No critical operational detail is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, yet the description adds significant context: expectedDrawing provenance and check timing, saveDrawing conditions (must be named), idempotencyKey purpose, and an example for code. It clearly enhances schema-only information.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a precise purpose: executing C# code with write access in Civil 3D. It explicitly scopes the tool to modifying the drawing ('Use this for operations that MODIFY the drawing'), which distinguishes it from the read-only sibling civil3d_query.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It provides clear usage criteria: use for modifications, not for reads; requires expectedDrawing from a prior civil3d_query; and warns against calling Database.SaveAs or queuing QSAVE, directing the user to the saveDrawing parameter instead. This fully covers when and how to use it versus alternatives.
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. Omit expectedDrawing only to bootstrap Database.Filename and Database.FingerprintGuid; otherwise supply it to guard the active drawing.
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | C# 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; | |
| expectedDrawing | No | Expected active drawing identity checked immediately before Civil API access. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden and does substantial work: it discloses read-only semantics ('no changes saved'), available globals (Document, CivilDoc, Database, Transaction, Editor), auto-imported namespaces, the JSON return mechanism, and the expectedDrawing guard vs. bootstrap behavior. It does not cover error behavior for failed compilation or thrown exceptions at runtime, which is a notable gap for a code-execution tool, but the disclosed traits are rich.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Three sentences, each earning its place: purpose/globals/return semantics, when-to-use, and the expectedDrawing rule. The first sentence is dense but not wasteful; the most critical differentiator (READ-ONLY) is front-loaded before supporting details.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a complex code-execution tool with no annotations and no output schema, the description covers the essentials: execution mode, environment globals, namespaces, return format, and the identity-guard parameter semantics. The main omissions are error/exception behavior and the exact failure mode when expectedDrawing mismatches, which an agent invoking arbitrary C# code would benefit from knowing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3. The description adds genuine value beyond the schema by explaining when to omit expectedDrawing entirely — 'Omit expectedDrawing only to bootstrap Database.Filename and Database.FingerprintGuid; otherwise supply it to guard the active drawing' — a semantic the schema's field descriptions do not convey.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb and resource: 'Execute C# code in Civil 3D in READ-ONLY mode (no changes saved).' It further scopes the tool with 'Use this for querying data: listing objects, getting properties, analyzing surfaces, etc.', which clearly differentiates it from the sibling civil3d_execute. An agent can tell immediately what this tool does and how it differs.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
'Use this for querying data' is an explicit when-to-use statement with concrete examples. The READ-ONLY framing implies that mutations belong to the sibling civil3d_execute, though it never names that alternative or states a when-not-to-use condition explicitly, so it stops short of a full 5.
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, or 'api_lookup' to search public metadata from already-loaded Civil 3D host assemblies. Skills are pre-built C# patterns you can adapt and execute via civil3d_execute or civil3d_query.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum list/search/api_lookup results to return (integer 1-50; default 20) | |
| query | No | Search query for 'search' or 'api_lookup' action | |
| action | Yes | list = browse skill metadata, search = find by keyword, get = read full skill, api_lookup = read-only public API metadata search | |
| cursor | No | Opaque nextCursor from a prior list/search call with the same filters | |
| assembly | No | Allowlisted loaded host assembly filter for api_lookup | |
| category | No | Filter by category (surfaces, alignments, points, etc.) | |
| namespace | No | Namespace prefix filter for api_lookup | |
| skillName | No | Skill name for 'get' action |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the behavioral disclosure burden. It clearly labels the tool as read-only ('Browse and read', 'read-only public API metadata search'), implying no state changes. It also notes that execution happens via sibling tools, which further clarifies that this tool itself does not modify anything. The absence of side-effect warnings is acceptable given the read-only framing.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is three concise sentences, each adding critical information: the core purpose, the list of actions, and the relationship to sibling tools. It front-loads the main purpose and avoids redundancy or filler. Every sentence earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a read-only tool with four actions, the description is nearly complete. It explains the actions, implies the output (list of skills, search results, full skill content, API metadata), and points to the execution siblings. While it doesn't detail pagination or output structure, those are typically understood and the schema covers cursor details. The description is sufficient for an agent to call it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so all eight parameters have descriptions in the schema. The tool description adds contextual meaning (e.g., what 'get' does, that api_lookup is read-only) but does not explain parameter syntax or constraints beyond the schema. This meets the baseline of 3 but does not exceed it.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb-resource pair ('Browse and read Civil 3D code skills') and immediately enumerates the four supported actions (list, search, get, api_lookup). It also distinguishes itself from the sibling tools by noting that skills 'can be adapted and execute via civil3d_execute or civil3d_query.' This clearly sets its scope apart.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explains the tool's role as a browsing/reading layer and explicitly points to the sibling tools for execution. It also differentiates between read actions (list/search/get) and the read-only metadata api_lookup. While it doesn't list explicit 'when not to use' scenarios, the purpose is clear enough for an agent to decide between this and its siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v1.0.0- First observed
civil3d_execute - First observed
civil3d_query - First observed
civil3d_skills
TDQS
Scored across 3 tools
Each tool has a clear, non-overlapping purpose: execute for write operations, query for read-only operations, and skills for browsing code templates. The read/write distinction is explicitly stated, so agents should not confuse execute and query.
All tools share the civil3d_ prefix and snake_case, but the suffixes mix verbs (execute, query) with a noun (skills), making it not a strictly consistent verb_noun pattern. The naming is still predictable and readable.
Three tools is a well-scoped set for a server that provides arbitrary C# execution capabilities; each tool serves a distinct and necessary function. The count falls within the typical 3-15 range.
The combination of execute and query covers the full range of Civil 3D operations (create, edit, delete, query), and skills fills the learning gap. No obvious missing functionality for the stated purpose.
Maintenance
Related MCP Connectors
- mcp-serverOAuthcom.make
Give your AI agents the tools to build, manage, and run automation workflows.
- SkilderOAuthai.skilder
One place to build, share, and govern the skills and tools your AI agents use at work.
- OolkinOAuthcom.oolkin
AI colleagues that keep your standards, your project and their reasoning between sessions
Image and video AI tools and your own pipelines, run from any AI assistant.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with Autodesk Civil 3D, allowing them to retrieve project data, create/modify/delete drawing elements, and execute code to automate Civil 3D operations.336MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to write and execute C# code directly inside Autodesk Civil 3D, providing full API access through code generation and execution.102MIT
- AlicenseAqualityCmaintenanceEnables 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.93MIT
- AlicenseNot gradedqualityAmaintenanceLets any MCP-compatible AI assistant read and edit Autodesk Civil 3D drawings through tools for alignments, surfaces, corridors, pipe networks, quantity takeoff, and cut/fill, using a local bridge plugin and named pipes.MIT