<!DOCTYPE html>
    <html lang="vi" xmlns="http://www.w3.org/1999/xhtml" prefix="og: http://ogp.me/ns#">
    <head>
<title>Cách kết nối MCP auto-cad với AI Chatgpt cực kỳ đơn giản |  Hoclaptrinh99.com</title>
<meta name="description" content="Cách kết nối MCP auto-cad với AI Chatgpt cực kỳ đơn giản - Savefile - Blog -...">
<meta name="keywords" content="blog lập trình">
<meta name="news_keywords" content="blog lập trình">
<meta name="author" content="Học Lập Trình 99">
<meta name="copyright" content="Học Lập Trình 99 [hoclaptrinh99@gmail.com]">
<meta name="generator" content="NukeViet v5.0">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google-site-verification" content="BSwsW_B32JEmlT2cuZD1IQZqLeh5J64CB7lFDySkFVY">
<meta name="google-adsense-account" content="ca-pub-8737821961639806">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta property="og:title" content="Cách kết nối MCP auto-cad với AI Chatgpt cực kỳ đơn giản">
<meta property="og:type" content="website">
<meta property="og:description" content="Savefile - Blog - https&#x3A;&#x002F;&#x002F;hoclaptrinh99.com&#x002F;blog&#x002F;savefile&#x002F;ai&#x002F;cach-ket-noi-mcp-auto-cad-voi-ai-chatgpt-cuc-ky-don-gian-31.html">
<meta property="og:site_name" content="Học Lập Trình 99">
<meta property="og:image" content="https://hoclaptrinh99.com/uploads/opengrap.png">
<meta property="og:image:url" content="https://hoclaptrinh99.com/uploads/opengrap.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1058">
<meta property="og:image:height" content="887">
<meta property="og:image:alt" content="Học Lập Trình 99">
<meta property="og:url" content="https://hoclaptrinh99.com/blog/savefile/ai/cach-ket-noi-mcp-auto-cad-voi-ai-chatgpt-cuc-ky-don-gian-31.html">
<link rel="shortcut icon" href="https://hoclaptrinh99.com/uploads/500058390_729034789638068_2489363526938716286_n.jpg">
<link rel="canonical" href="https://hoclaptrinh99.com/blog/savefile/ai/cach-ket-noi-mcp-auto-cad-voi-ai-chatgpt-cuc-ky-don-gian-31.html">
<link rel="alternate" href="https://hoclaptrinh99.com/blog/rss/" title="Blog" type="application/rss+xml">
<link rel="alternate" href="https://hoclaptrinh99.com/blog/rss/nukeviet/" title="Blog - NUKEVIET" type="application/rss+xml">
<link rel="alternate" href="https://hoclaptrinh99.com/blog/rss/php-mysql/" title="Blog - PHP MYSQL" type="application/rss+xml">
<link rel="alternate" href="https://hoclaptrinh99.com/blog/rss/html-css-js/" title="Blog - HTML CSS JS" type="application/rss+xml">
<link rel="alternate" href="https://hoclaptrinh99.com/blog/rss/python/" title="Blog - PYTHON" type="application/rss+xml">
<link rel="alternate" href="https://hoclaptrinh99.com/blog/rss/linux/" title="Blog - LINUX" type="application/rss+xml">
<link rel="alternate" href="https://hoclaptrinh99.com/blog/rss/khac/" title="Blog - KHÁC" type="application/rss+xml">
<link rel="alternate" href="https://hoclaptrinh99.com/blog/rss/ai/" title="Blog - AI" type="application/rss+xml">
<link rel="search" type="application/opensearchdescription+xml" href="https://hoclaptrinh99.com/seek/opensearch/blog/" title="Blog">
<link rel="preload" as="font" href="/assets/fonts/fontawesome-webfont.woff2" type="font/woff2" crossorigin>
<link rel="preload" as="font" href="/themes/default/fonts/NukeVietIcons.woff2" type="font/woff2" crossorigin>
<link rel="preload" as="image" href="/themes/ts_sharecode/images/header.png" type="image/png">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/assets/js/jquery/jquery.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/assets/js/language/vi.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/assets/js/DOMPurify/purify3.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/assets/js/global.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/assets/js/site.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/default/js/news.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/js/main.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/js/sweetalert.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/toastr/toastr.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/toastr/tienganh.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/php-email-form/validate.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/bootstrap/js/bootstrap.bundle.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/waypoints/jquery.waypoints.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/counterup/counterup.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/jquery.easing/jquery.easing.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/owl.carousel/owl.carousel.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/js/main.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/aos/aos.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/assets/js/select2/select2.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/js/custom.js" type="text/javascript">
<link rel="preload" as="script" href="https://hoclaptrinh99.com/themes/ts_sharecode/js/bootstrap.min.js" type="text/javascript">
<link rel="preload" as="style" href="/assets/css/core.r.min.css?t=1764339859" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/assets/css/font-awesome.min.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/css/bootstrap.min.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/css/style.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/css/style.responsive.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/css_custom/sweetalert.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/toastr/toastr.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/css/style.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/animate.css/animate.min.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/owl.carousel/assets/owl.carousel.min.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/remixicon/remixicon.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/boxicons/css/boxicons.min.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/icofont/icofont.min.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/assets/js/select2/select2.min.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/aos/aos.css" type="text/css">
<link rel="preload" as="style" href="https://hoclaptrinh99.com/themes/ts_sharecode/css/custom.css" type="text/css">
<link rel="stylesheet" href="/assets/css/core.r.min.css?t=1764339859">
<link rel="stylesheet" href="https://hoclaptrinh99.com/assets/css/font-awesome.min.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/css/bootstrap.min.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/css/style.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/css/style.responsive.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/css_custom/sweetalert.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/toastr/toastr.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/css/style.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/animate.css/animate.min.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/owl.carousel/assets/owl.carousel.min.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/remixicon/remixicon.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/boxicons/css/boxicons.min.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/icofont/icofont.min.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/assets/js/select2/select2.min.css">
<link rel="stylesheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/aos/aos.css">
<link rel="StyleSheet" href="https://hoclaptrinh99.com/themes/ts_sharecode/css/custom.css">
<style type="text/css">
    body{background: #fff;}
</style>
    </head>
    <body>
<div class="container-fluid"style="background-color:#fff;">
<div id="print">
    <div id="hd_print">
        <h2 class="pull-left">Học Lập Trình 99</h2>
        <p class="pull-right"><a title="Học Lập Trình 99" href="https://hoclaptrinh99.com/">https://hoclaptrinh99.com</a></p>
    </div>
    <div class="clear"></div>
    <hr />
    <div id="content">
        <h1>Cách kết nối MCP auto-cad với AI Chatgpt cực kỳ đơn giản</h1>
        <ul class="list-inline">
            <li>Thứ tư, 02 Tháng M. hai 2026 8:14 CH</li>
            <li class="hidden-print txtrequired"><em class="fa fa-print">&nbsp;</em><a title="In ra" href="https://hoclaptrinh99.com/#" data-toggle="winCMD" data-cmd="print">In ra</a></li>
            <li class="hidden-print txtrequired"><em class="fa fa-power-off">&nbsp;</em><a title="Đóng cửa sổ này" href="https://hoclaptrinh99.com/#"  data-toggle="winCMD" data-cmd="close">Đóng cửa sổ này</a></li>
        </ul>
        <div class="clear"></div>
        <div id="hometext">
        </div>
                <div class="imghome">
            <img alt="1786366942167" src="https://hoclaptrinh99.com/uploads/blog/2026_12/1786366942167.jpg" width="460" class="img-thumbnail" />
                        <p>
                <em>1786366942167</em>
            </p>
        </div>
        <div class="clear"></div>
        <div id="bodytext" class="clearfix">
            <p style="margin-left:-.25pt;"><strong>01 / TỔNG QUAN</strong></p><h1 style="margin-left:-.25pt;">Kết nối AutoCAD MCP với OpenAI Codex</h1><p style="margin-left:0cm;"><span style="color:rgb(23, 50, 77);"><strong>Hướng dẫn triển khai trên Windows 10/11</strong></span></p><p style="margin-left:-.25pt;">Codex CLI và Visual Studio Code • HTTP localhost • Không cần Docker</p><h2 style="margin-left:-.25pt;">Mục tiêu</h2><p style="margin-left:-.25pt;">Điều khiển AutoCAD bằng yêu cầu tiếng Việt: đọc bản vẽ, tạo hình học, quản lý layer, ghi kích thước và chỉnh sửa file DWG, tùy công cụ mà MCP cung cấp.</p><h2 style="margin-left:-.25pt;">Kiến trúc</h2><p style="margin-left:-.25pt;">Codex CLI / Codex Extension (VS Code)</p><p style="margin-left:-.25pt;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|</p><p style="margin-left:-.25pt;">&nbsp; &nbsp; &nbsp; ~/.codex/config.toml</p><p style="margin-left:-.25pt;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| HTTP</p><p style="margin-left:-.25pt;">&nbsp; &nbsp; &nbsp; 127.0.0.1:8765/mcp&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;acad-mcp&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Windows COM</p><p style="margin-left:-.25pt;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AutoCAD</p><h2 style="margin-left:-.25pt;">Trạng thái thực tế</h2><p style="margin-left:-.25pt;">Máy đã cài uv/uvx, package acad-mcp nhận diện 72 công cụ và tìm thấy AutoCAD. Cổng 8765 đã LISTENING và có kết nối TCP. Tuy nhiên, lần gọi autocad.status báo Transport send error. Chưa nghiệm thu được việc điều khiển bản vẽ.</p><h2 style="margin-left:-.25pt;">Nội dung tài liệu</h2><p style="margin-left:-.25pt;">02 Cài đặt phần mềm • 03 Khởi động và cấu hình MCP • 04 Sử dụng CLI và VS Code • 05 Kiểm thử và chỉnh sửa DWG • 06 Tự động hóa • 07 Xử lý lỗi • 08 Nghiệm thu và tham khảo.</p><p style="margin-left:-.25pt;"><strong>02 / CÀI ĐẶT</strong></p><h1 style="margin-left:-.25pt;">Chuẩn bị môi trường Windows</h1><p style="margin-left:-.25pt;">Cài AutoCAD bản đầy đủ có hỗ trợ COM/ActiveX. Kiểm tra khả năng tương thích của phiên bản đang sử dụng. Mở AutoCAD và tạo bản vẽ trống để thử nghiệm. <strong>Cài Node.js, VS Code và uv (CMD)</strong></p><p style="margin-left:-.25pt;">winget install --id=OpenJS.NodeJS.LTS -e winget install --id=Microsoft.VisualStudioCode -e winget install --id=astral-sh.uv -e</p><p style="margin-left:-.25pt;">Đóng CMD và mở lại để cập nhật PATH. Bỏ qua các phần mềm đã có.</p><p style="margin-left:-.25pt;">node -v npm -v uv --version uvx --version where uvx</p><h2 style="margin-left:-.25pt;">Cài Codex và extension</h2><p style="margin-left:-.25pt;">npm install -g @openai/codex codex --version codex login</p><p style="margin-left:-.25pt;">code --install-extension openai.chatgpt</p><p style="margin-left:-.25pt;">Đăng nhập tài khoản ChatGPT theo hướng dẫn. Có thể cài extension qua Ctrl + Shift + X, tìm openai.chatgpt, nhà phát hành OpenAI. <strong>Cập nhật Codex khi cần</strong></p><p style="margin-left:-.25pt;">npm install -g @openai/codex@latest</p><p style="margin-left:-.25pt;"><strong>03 / MCP SERVER</strong></p><h1 style="margin-left:-.25pt;">Khởi động HTTP và đăng ký Codex</h1><p style="margin-left:-.25pt;">Kiểm tra package bên thứ ba acad-mcp trước khi sử dụng. Lệnh uvx acad-mcp trên máy bạn mở trình cài đặt Claude Desktop; nhấn Ctrl + C để thoát, không cần cấu hình Claude. <strong>CMD 1: mở AutoCAD trước, sau đó chạy</strong></p><p style="margin-left:-.25pt;">uvx acad-mcp --http</p><p style="margin-left:-.25pt;">Giữ tiến trình chạy. CMD 2: kiểm tra cổng và đăng ký server. Chỉ xóa cấu hình autocad cũ nếu đã tồn tại và cần thay thế.</p><p style="margin-left:0cm;text-align:justify;">netstat -ano | findstr :8765 codex mcp remove autocad codex mcp add autocad --url http://127.0.0.1:8765/mcp codex mcp list codex mcp get autocad&nbsp;<strong>Mở file cấu hình (CMD)</strong></p><p style="margin-left:-.25pt;">notepad &quot;%USERPROFILE%\.codex\config.toml&quot;</p><p style="margin-left:-.25pt;">Giữ nguyên các phần khác, chỉnh đúng một khối autocad:</p><p style="margin-left:-.25pt;">&#91;mcp_servers.autocad&#93; url = &quot;http://127.0.0.1:8765/mcp&quot; enabled = true startup_timeout_sec = 120 tool_timeout_sec = 120</p><p style="margin-left:-.25pt;">Không dùng đồng thời command/args của STDIO trong khối HTTP. enabled chỉ xác nhận đăng ký cấu hình; Auth Unsupported không tự nó là lỗi. Timeout 120 giây là giá trị đề xuất, không sửa được lỗi giao thức.</p><p style="margin-left:-.25pt;"><strong>04 / SỬ DỤNG</strong></p><h1 style="margin-left:-.25pt;">Codex CLI và Visual Studio Code</h1><h2 style="margin-left:-.25pt;">Phương án A: Codex CLI</h2><p style="margin-left:-.25pt;">codex</p><p style="margin-left:-.25pt;">Trong giao diện Codex, nhập:</p><p style="margin-left:-.25pt;">/mcp</p><p style="margin-left:-.25pt;">/mcp verbose</p><p style="margin-left:-.25pt;">Kỳ vọng autocad: connected, số công cụ tùy phiên bản. Nếu failed (0 tools), chuyển sang phần xử lý lỗi.</p><h2 style="margin-left:-.25pt;">Phương án B: VS Code (khuyến nghị)</h2><p style="margin-left:-.25pt;">Tạo thư mục D:\AutoCAD-MCP, mở bằng VS Code. Codex extension dùng chung cấu hình</p><p style="margin-left:-.25pt;">~/.codex/config.toml với CLI trong cùng môi trường Windows. Không cần tạo .vscode/mcp.json cho Codex.</p><p style="margin-left:-.25pt;">mkdir D:\AutoCAD-MCP code D:\AutoCAD-MCP</p><p style="margin-left:-.25pt;">Giữ MCP Server chạy. Trong VS Code nhấn Ctrl + Shift + P, chọn Developer: Reload Window. Mở biểu tượng Codex, đăng nhập, tạo cuộc trò chuyện mới và dùng môi trường Local nếu có tùy chọn. Không dùng phiên cloud/WSL để truy cập localhost Windows nếu chưa cấu hình mạng phù hợp.</p><h2 style="margin-left:-.25pt;">Prompt kiểm tra chỉ đọc</h2><p style="margin-left:-.25pt;">Hãy liệt kê các công cụ AutoCAD MCP hiện có. Gọi công cụ status đúng một lần, đọc tên bản vẽ đang mở và danh sách layer. Không chỉnh sửa bản vẽ. Nếu lỗi, hiển thị đầy đủ thông báo và dừng lại.</p><p style="margin-left:-.25pt;">Chỉ chuyển sang vẽ khi công cụ đọc trả về kết quả thành công.</p><p style="margin-left:-.25pt;"><strong>05 / KIỂM THỬ</strong></p><h1 style="margin-left:-.25pt;">Vẽ cơ bản và chỉnh sửa DWG</h1><h2 style="margin-left:-.25pt;">Bài test 1: hình học</h2><p style="margin-left:-.25pt;">Sử dụng trực tiếp AutoCAD MCP trên bản vẽ mới. Thiết lập đơn vị mm, tạo layer TEST, vẽ hình chữ nhật từ (0,0) đến (4000,3000), đường tròn tâm (2000,1500) bán kính 500. Ghi kích thước, Zoom Extents và kiểm tra đối tượng. Lưu thành Test_MCP.dwg trong thư mục làm việc, không ghi đè file có sẵn. Nếu lỗi, dừng lại.</p><h2 style="margin-left:-.25pt;">Bài test 2: mặt bằng nhà</h2><p style="margin-left:-.25pt;">Tạo bản vẽ mới 6000 × 15500 mm. Tường bao 200 mm, tường ngăn 100 mm. Phân khu dọc nhà: khách 5000 mm, bếp 4500 mm, ngủ 3500 mm, vệ sinh/giặt 2500 mm (kích thước phân khu gồm tường). Tạo layer WALL, DOOR, WINDOW, DIM, TEXT, FURNITURE; ghi tên và kích thước. Đây chỉ là mẫu thử, chưa có giao thông và cầu thang hoàn chỉnh, không dùng thi công.</p><h2 style="margin-left:-.25pt;">Chỉnh sửa file DWG có sẵn</h2><p style="margin-left:-.25pt;">Mở file trong AutoCAD. Dùng Save As tạo bản sao trước khi yêu cầu AI thao tác. Kiểm tra bản sao đang là tài liệu hoạt động.</p><p style="margin-left:-.25pt;">Prompt: Đọc tên file, đơn vị, layer, block, đối tượng và kích thước. Chỉ chỉnh sửa đúng đối tượng tôi chỉ định; giữ nguyên hệ tọa độ và các phần không liên quan. Báo cáo phương án trước khi sửa. Sau khi sửa, kiểm tra kích thước và lưu bản sao có hậu tố _AI_EDITED.dwg. Không ghi đè file gốc.</p><p style="margin-left:-.25pt;">Nếu lỗi khi gọi công cụ ghi, kiểm tra bản vẽ trước khi thử lại để tránh tạo đối tượng trùng.</p><p style="margin-left:-.25pt;"><strong>06 / TỰ ĐỘNG HÓA</strong></p><h1 style="margin-left:-.25pt;">Khởi động nhanh và quy tắc dự án</h1><p style="margin-left:-.25pt;">Tạo start_mcp.bat trong D:\AutoCAD-MCP. Mở AutoCAD trước khi chạy file.</p><p style="margin-left:-.25pt;">@echo off title AutoCAD MCP Server uvx acad-mcp --http pause</p><p style="margin-left:-.25pt;">Tạo start_vscode.bat cùng thư mục:</p><p style="margin-left:-.25pt;">@echo off cd /d &quot;%~dp0&quot; code .</p><p style="margin-left:-.25pt;">Tạo check_mcp.bat để kiểm tra cấu hình và cổng:</p><p style="margin-left:-.25pt;">@echo off uv --version codex --version codex mcp list netstat -ano | findstr :8765 curl -i --max-time 5 http://127.0.0.1:8765/mcp pause</p><h2 style="margin-left:-.25pt;">Tạo AGENTS.md trong thư mục làm việc</h2><p style="margin-left:-.25pt;">Nội dung đề xuất: Ưu tiên AutoCAD MCP; kiểm tra trạng thái trước khi thao tác; chỉ chỉnh sửa đúng yêu cầu; giữ nguyên đơn vị và hệ tọa độ; tạo bản sao trước khi sửa; không ghi đè bản gốc; kiểm tra kết quả; dừng và báo lỗi đầy đủ khi mất kết nối; trao đổi bằng tiếng Việt.</p><p style="margin-left:-.25pt;">Quy trình hằng ngày: mở AutoCAD, chạy start_mcp.bat (nếu server chưa chạy), kiểm tra cổng, chạy start_vscode.bat và mở Codex. Các file BAT là mẫu chưa được chạy thử trên máy Windows của bạn.</p><p style="margin-left:-.25pt;"><strong>07 / KHẮC PHỤC LỖI</strong></p><h1 style="margin-left:-.25pt;">Chẩn đoán kết nối MCP</h1><p style="margin-left:-.25pt;">404 Not Found: URL ZIP của repository ajaquin8/autocad-mcp đã trả về 404 trên máy bạn. Không dùng lại URL đó. Package acad-mcp thay thế đã chạy được trình kiểm tra.</p><p style="margin-left:-.25pt;">failed (0 tools): kiểm tra server còn chạy, URL chính xác, cấu hình không trùng và khởi động lại Codex. Không dùng uvx acad-mcp ở chế độ STDIO khi chưa xác minh entrypoint server vì lệnh này từng mở trình cài đặt tương tác.</p><p style="margin-left:-.25pt;">Transport send error: chưa xác định nguyên nhân. Kiểm tra log server ngay khi lỗi xuất hiện và log Codex:</p><p style="margin-left:-.25pt;">netstat -ano | findstr :8765 curl -i --max-time 5 http://127.0.0.1:8765/mcp notepad &quot;%USERPROFILE%\.codex\log\codex-tui.log&quot;</p><p style="margin-left:-.25pt;">GET thông thường có thể trả 400/405/406 hoặc timeout với stream; không đủ để kết luận MCP hoạt động. LISTENING và ESTABLISHED chỉ xác nhận tầng TCP. <strong>Kiểm thử độc lập bằng MCP Inspector</strong></p><p style="margin-left:-.25pt;">npx @modelcontextprotocol/inspector</p><p style="margin-left:-.25pt;">Chọn Streamable HTTP, URL http://127.0.0.1:8765/mcp, Connect, Tools, List Tools và gọi status. Nếu Inspector cũng lỗi, kiểm tra server/giao thức/COM; nếu thành công nhưng Codex lỗi, kiểm tra phiên bản, cấu hình và log Codex.</p><p style="margin-left:-.25pt;">Khởi động lại theo thứ tự: thoát Codex, dừng server bằng Ctrl+C, lưu bản vẽ, mở AutoCAD, chạy server, mở Codex và gọi status một lần. Nếu cổng bị chiếm, dùng tasklist /FI &quot;PID eq &lt;PID&gt;&quot; với PID thực tế để xác định tiến trình trước khi dừng.</p><p style="margin-left:-.25pt;"><strong>08 / NGHIỆM THU</strong></p><h1 style="margin-left:-.25pt;">Checklist và tài liệu tham khảo</h1><p style="margin-left:-.25pt;">&#91; &#93; AutoCAD mở và có bản vẽ thử nghiệm</p><p style="margin-left:-.25pt;">&#91; &#93; uv, uvx và Codex hoạt động</p><p style="margin-left:-.25pt;">&#91; &#93; MCP Server lắng nghe tại 127.0.0.1:8765</p><p style="margin-left:-.25pt;">&#91; &#93; Codex đăng ký đúng URL</p><p style="margin-left:-.25pt;">&#91; &#93; MCP kết nối và liệt kê công cụ</p><p style="margin-left:-.25pt;">&#91; &#93; Gọi status thành công</p><p style="margin-left:-.25pt;">&#91; &#93; Đọc bản vẽ và layer thành công</p><p style="margin-left:-.25pt;">&#91; &#93; Vẽ hình học đúng kích thước</p><p style="margin-left:-.25pt;">&#91; &#93; Lưu file DWG mới và mở lại kiểm tra</p><p style="margin-left:-.25pt;">&#91; &#93; Kiểm thử thành công trên VS Code</p><h2 style="margin-left:-.25pt;">An toàn</h2><p style="margin-left:-.25pt;">Chỉ bind localhost, không mở cổng ra Internet. Không chạy Administrator nếu không cần. Kiểm tra nguồn package bên thứ ba. Sao lưu DWG và kiểm tra mọi thay đổi trước khi sử dụng thực tế.</p><h2 style="margin-left:-.25pt;">Tham khảo</h2><p style="margin-left:-.25pt;">https://github.com/thurdevv/acad-mcp https://pypi.org/project/acad-mcp/ https://developers.openai.com/codex/ https://docs.astral.sh/uv/ https://modelcontextprotocol.io/</p><p style="margin-left:-.25pt;">https://marketplace.visualstudio.com/items?itemName=openai.chatgpt</p><p style="margin-left:-.25pt;">Giới hạn: tài liệu tổng hợp từ quá trình setup đã trao đổi; chưa kiểm thử trực tiếp trên máy Windows và chưa xác nhận lỗi Transport send error đã được xử lý.</p>
        </div>
                <div id="author">
                        <p>
                <strong>Tác giả:</strong>
                <a href="https://hoclaptrinh99.com/blog/author/Nguyen-Lam/">Nguyễn Lâm</a>
            </p>
        </div>
    </div>
    <div id="footer" class="clearfix">
        <div id="url">
            <strong>URL của bản tin này: </strong><a href="https://hoclaptrinh99.com/blog/savefile/ai/cach-ket-noi-mcp-auto-cad-voi-ai-chatgpt-cuc-ky-don-gian-31.html" title="Cách kết nối MCP auto-cad với AI Chatgpt cực kỳ đơn giản">https://hoclaptrinh99.com/blog/savefile/ai/cach-ket-noi-mcp-auto-cad-voi-ai-chatgpt-cuc-ky-don-gian-31.html</a>
        </div>
        <div class="clear"></div>
        <div class="copyright">
            &copy; Học Lập Trình 99
        </div>
        <div id="contact">
            <a href="mailto:hoclaptrinh99@gmail.com">hoclaptrinh99@gmail.com</a>
        </div>
    </div>
</div>
</div>
        <div id="timeoutsess" class="chromeframe">
            Bạn đã không sử dụng site, <a data-toggle="timeoutsesscancel" href="https://hoclaptrinh99.com/#">Bấm vào đây để duy trì trạng thái đăng nhập</a>. Thời gian chờ: <span id="secField"> 60 </span> giây
        </div>
        <div id="openidResult" class="nv-alert" style="display:none"></div>
        <div id="openidBt" data-result="" data-redirect=""></div>
<script src="https://hoclaptrinh99.com/assets/js/jquery/jquery.min.js"></script>
<script>var nv_base_siteurl="/",nv_assets_dir="assets",nv_lang_data="vi",nv_lang_interface="vi",nv_name_variable="nv",nv_fc_variable="op",nv_lang_variable="language",nv_module_name="blog",nv_func_name="savefile",nv_is_user=0, nv_my_ofs=-5,nv_my_abbr="EST",nv_cookie_prefix="nv4",nv_check_pass_mstime=1738000,nv_area_admin=0,nv_safemode=0,theme_responsive=1,nv_recaptcha_ver=2,nv_recaptcha_sitekey="",nv_recaptcha_type="image",nv_turnstile_sitekey="",XSSsanitize=1,nv_jsdate_get="dd-mm-yyyy",nv_jsdate_post="dd/mm/yyyy",nv_gfx_width="150",nv_gfx_height="40",nv_gfx_num="6";</script>
<script src="https://hoclaptrinh99.com/assets/js/language/vi.js"></script>
<script src="https://hoclaptrinh99.com/assets/js/DOMPurify/purify3.js"></script>
<script src="https://hoclaptrinh99.com/assets/js/global.js"></script>
<script src="https://hoclaptrinh99.com/assets/js/site.js"></script>
<script src="https://hoclaptrinh99.com/themes/default/js/news.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/js/main.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/js/sweetalert.min.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/toastr/toastr.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/toastr/tienganh.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/php-email-form/validate.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/waypoints/jquery.waypoints.min.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/counterup/counterup.min.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/jquery.easing/jquery.easing.min.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/owl.carousel/owl.carousel.min.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/assets/js/main.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/assets/vendor/aos/aos.js"></script>
<script src="https://hoclaptrinh99.com/assets/js/select2/select2.min.js"></script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/js/custom.js"></script>
<script>        // Debug AOS
        console.log("Checking AOS...");
        function initAOS() {
            if (typeof AOS !== "undefined") {
                console.log("AOS found, initializing...");
                AOS.init({
                    duration: 1000,
                    easing: "ease-in-out",
                    once: false,
                    mirror: true,
                    offset: 50,
                    delay: 0
                });
                console.log("AOS initialized successfully");
            } else {
                console.error("AOS library not found!");
            }
        }
        if (document.readyState === "loading") {
            document.addEventListener("DOMContentLoaded", initAOS);
        } else {
            initAOS();
        }</script>
<script src="https://hoclaptrinh99.com/themes/ts_sharecode/js/bootstrap.min.js"></script>
<script>
        $(function() {
            // Check wallet transaction status - chỉ hiển thị 1 lần
            $.ajax({
                url: '/index.php?language=vi&nv=wallet&op=check_transaction',
                type: 'POST',
                dataType: 'json',
                success: function(response) {
                    if (response.status === 'success' && response.transaction_info) {
                        swal({
                            title: "Thông báo",
                            text: response.transaction_info,
                            type: "success"
                        });
                    }
                },
                error: function() {
                    console.log('Error checking wallet transaction');
                }
            });
        });
        </script>
</body>
</html>