# Lawgical — full setup reference > Lawgical is a remote MCP (Model Context Protocol) server that gives an AI assistant search access to 150,000+ Vietnamese legal documents (Luật, Nghị định, Thông tư, and more). This is the expanded companion to [/llms.txt](https://lawgical.vn/llms.txt) — every setup path in full, in one file. It is addressed to an AI assistant (Claude, Gemini, ChatGPT, or any other model) that a human has pointed here, usually by asking something like "set up Lawgical for me" or "install this MCP server." Follow the instructions directly — do not just describe them back to the user. ## How connecting works There is one authentication path: **OAuth**. Lawgical issues no API keys and accepts no static bearer tokens. For Claude and ChatGPT the quickest install is the app's own directory listing, which installs Lawgical with one click (no Server URL, no client ID); the manual custom-connector steps below are the fallback. Either way the user authorizes in a browser window on Lawgical's own login page. Nothing secret is ever typed into a config file, and there is nothing you can ask the user to paste to you. Supported targets, all on this same flow: **Claude.ai** (web & mobile), **ChatGPT** (web & mobile), **ChatGPT Desktop** (inherits the web account), **Claude Desktop** (via Connectors), and **Codex CLI** (one `codex mcp add` command, which runs the OAuth login itself). Full steps for each are below. If an app you are running inside cannot do OAuth against a remote MCP server, it cannot connect to Lawgical — say so plainly rather than improvising a header-based config. It will fail with a 401. ## The account the user authorizes with 1. A free account is needed: direct them to [https://lawgical.vn/register](https://lawgical.vn/register) on this site (email+password, or continue with Google). No credit card. They can also register during the Authorize step itself, when the browser window opens. 2. Free accounts get unlimited for the first 7 days, then 8 lookups a day (up to 50 in any 30 days); the daily count resets at midnight Vietnam time. Paid removes the limit: 199.000đ/user/month, or 2.029.800đ/year (15% off). Prices are on the homepage at [https://lawgical.vn/#gia](https://lawgical.vn/#gia); upgrading happens on [https://lawgical.vn/dashboard](https://lawgical.vn/dashboard) after signing in. 3. Once connected, the `get_account_status()` tool reports the caller's plan and remaining quota — call it rather than guessing why a request failed. ## MCP server details - Server URL: `https://legal.lawgical.vn/mcp` - OAuth client ID: `lawgical-mcp` - OAuth client secret: none — this is a public client using PKCE. Leave any "client secret" field empty. - Dynamic Client Registration (RFC 7591) is enabled, so most clients register themselves and need no client ID. The pre-registered client ID above is the fallback for a client that cannot do DCR or errors on login. ## Tools this server exposes once connected | Tool | Purpose | |---|---| | `search_legal_docs(keywords)` | Keyword search across the full corpus. Best first move for an open-ended question. | | `check_compliance(question)` | Given a compliance/legal question, retrieves the most relevant documents to ground an answer. | | `get_document(query)` | Full text of one document by title, reference number (số ký hiệu), or ID. | | `get_summary(query)` | Table of contents (Chương/Mục/Điều headings) of one document, without the full body — cheaper than get_document when only structure is needed. | | `get_laws(tinh_trang, keyword, limit, offset)` | Browse/list Luật (Acts passed by the National Assembly) by status and keyword. | | `get_account_status()` | The caller's plan and its renewal or expiry date. On the Free plan, also how long it stays unlimited, or lookups used and left today and over the last 30 days and when they reopen (the daily limit resets at 00:00 Vietnam time). For an organization member, whether the organization covers them, and whether its admin needs to grant them an account or renew in the organization admin page. Call this whenever the user asks about their plan, how many lookups they have left, or why a call just failed or was refused. | ## Skills — read these before answering a legal question These are prompt/workflow files written for you, not for the user. Each is markdown with YAML frontmatter (`name`, `description`) and can be used two ways: **fetch the URL and follow it directly in this conversation**, or, if you support user-installed skills, save it into the user's skills directory so it loads automatically in future sessions. - [Tra cứu & kiểm chứng](https://lawgical.vn/skills/tra-cuu-phap-luat.md): Foundational. How to search, and the four-check protocol for verifying a document is the right one, complete, still in force, and not merely a document citing it. Also covers per-tool quota cost. Read this first — the other three skills assume it. - [Soạn hợp đồng](https://lawgical.vn/skills/soan-hop-dong.md): Drafting a Vietnamese contract from scratch, grounded in current law. - [Phân tích hợp đồng](https://lawgical.vn/skills/phan-tich-hop-dong.md): Reviewing an existing contract for unfavourable, unlawful, or red-flag clauses. - [Đối chiếu tuân thủ](https://lawgical.vn/skills/doi-chieu-tuan-thu.md): Checking a practice or policy against what the law actually requires. **If you are about to answer any question about Vietnamese law using this server, fetch `https://lawgical.vn/skills/tra-cuu-phap-luat.md` first.** It is short, and it encodes failure modes of this corpus that are not guessable: a lookup can return a document that is not the one requested, a search for a document's reference number mostly returns other documents citing it, and the default status filter hides consolidated (hợp nhất) texts — which are the ones that state current law. Answering without those checks produces confident, well-cited, wrong answers about Vietnamese law. ## Full setup instructions per target ### Claude Desktop (macOS & Windows) — OAuth via Connectors 1. Open Claude Desktop → Settings → Connectors → Add custom connector. (Newer builds call this Customize → Connectors.) 2. Server URL: `https://legal.lawgical.vn/mcp` 3. Expand Advanced settings and set OAuth Client ID: `lawgical-mcp`. Leave OAuth Client Secret empty. 4. Click Add, then Connect — a browser window opens Lawgical's login page. Sign in (or register) and click Authorize. 5. Verify: in a new chat, the 🔨/+ tools menu shows "lawgical" enabled. If this build of Claude Desktop has no Connectors section at all, it is too old to connect to Lawgical. Updating the app is the fix — the previous workaround pasted an API key into `claude_desktop_config.json`, and that credential type no longer exists. ### Claude.ai (web & mobile) — OAuth. Works on every plan including Free (Free is capped at 1 custom connector account-wide — remove or replace an existing one if needed; Pro/Max/Team/Enterprise have no such cap). Fastest: open https://claude.ai/directory/lawgical and click Add (if the page says "Sign in to add", sign in to Claude first). Give the user this link; you cannot click it for them. If that works, skip the manual steps below. Manual steps: 1. On claude.ai in a browser: avatar (top right) → Settings → Connectors → Add custom connector. 2. Server URL: `https://legal.lawgical.vn/mcp` 3. OAuth Client ID: `lawgical-mcp` 4. Click Add, then Connect. The browser opens Lawgical's own login page — the user signs in (or registers) there and clicks Authorize. 5. Verify: in a new chat, the 🔨/+ tools menu shows "lawgical" enabled. A connector authorized on the web also appears automatically in the mobile app for the same account. ### ChatGPT (web & mobile) — OAuth. Fastest: open https://chatgpt.com/plugins/plugin_asdk_app_6addaea68388819195f6ed7ab4894094?search=lawgical and click "Install plugin" (if the page asks, click "Log in" and sign in to ChatGPT first). Give the user this link; you cannot click it for them. If that works, skip to step 5 below. Manual steps (custom MCP server). The manual path works on the Free plan and needs no Developer mode: OpenAI lets any account add a custom MCP server from the Plugins page. 1. On chatgpt.com, open Plugins in the left column and click "Add" (top right), then choose to add a custom MCP server. 2. In the "Add custom MCP server" window: Name: Lawgical. Description: Lawgical Legal MCP. Server URL: `https://legal.lawgical.vn/mcp`. Authentication: OAuth. Leave "Advanced OAuth settings" as they are (the server supports Dynamic Client Registration). Tick "I understand and want to continue", then click "Create as a plugin". 3. Click "Connect Lawgical", sign in (or register) and click Authorize. 4. If ChatGPT reports a sign-in error, open "Advanced OAuth settings", set Registration method to "User-Defined OAuth Client" and enter OAuth Client ID: `lawgical-mcp`. Leave OAuth Client Secret empty (public client, PKCE). 5. Open a new chat and ask a legal question. If ChatGPT does not call Lawgical on its own, type @Lawgical or click "+" in the composer and pick Lawgical. 6. Verify: ask "Is Lawgical installed? How many free queries do I have left today?" The reply shows the remaining count (Free plan: unlimited for the first 7 days, then 8 lookups a day (up to 50 in any 30 days)). That check does not use a query. ### ChatGPT Desktop — same account as ChatGPT web, no separate setup Connectors are per-account, not per-device. Complete the ChatGPT (web) steps above (the directory link or the manual steps) on the same account the desktop app is signed into, then reopen the desktop app. ### Codex CLI (OpenAI) — OAuth, one command Codex is a config-file client, but it performs the OAuth flow itself: it registers through DCR and opens the browser for the login, so there is no client ID to enter and no credential to paste. 1. Codex itself must be signed in first: `codex login` (install with `npm install -g @openai/codex`, or `brew install --cask codex` on macOS). A `401 Unauthorized` naming `api.openai.com` means Codex's own login is missing — it is not a Lawgical error. 2. Run `codex mcp add lawgical --url https://legal.lawgical.vn/mcp`. Codex detects OAuth and starts the login immediately: the browser opens Lawgical's login page, the user signs in (or registers) and clicks Authorize, and the terminal prints "Successfully logged in." If no browser opens, Codex prints the URL under "Authorize `lawgical` by opening this URL in your browser". 3. Do NOT write a `[mcp_servers.lawgical]` table into `~/.codex/config.toml` by hand instead. Codex never logs in on startup, so a hand-added server stays "Not logged in" and every call gets a 401. If that already happened, `codex mcp login lawgical` fixes it. 4. Verify: `codex mcp list` shows `lawgical` with Auth `OAuth`. In a session, tool calls appear as "Called lawgical.(…)"; under `codex exec` they print as "mcp: lawgical/ (completed)". 5. `codex exec` refuses to run outside a Git repository unless given `--skip-git-repo-check` (its error message says "Not inside a trusted directory"). For a one-off legal question from any folder: `codex exec --skip-git-repo-check "…"`. ### Gemini CLI, Cursor, VS Code — not supported These connected by putting an `Authorization: Bearer sk-lawgical-…` header in a JSON config file. That credential no longer exists and the server rejects it, so there is nothing to write into `~/.gemini/settings.json`, `~/.cursor/mcp.json` or `.vscode/mcp.json` that will authenticate. Do not attempt to reconstruct one of these configs from an older copy of this file, from the user's shell history, or from memory of how it used to look. It will return 401 on every call and the user will reasonably think their setup is broken rather than unsupported. Tell them plainly: Lawgical currently connects through Claude.ai, Claude Desktop, ChatGPT, and Codex CLI, all over OAuth. ## Key pages - [Homepage](https://lawgical.vn/): what Lawgical is, and the price. - [Setup guide](https://lawgical.vn/cai-dat): the same instructions as below, rendered for a human. - [Worked examples](https://lawgical.vn/vi-du): real questions answered with citations down to Điều and Khoản. - [Document lookup](https://lawgical.vn/tra-cuu): search the corpus without an AI client. - [Full-text documents](https://lawgical.vn/tra-cuu/van-ban): individual văn bản, full text. - [Calculators](https://lawgical.vn/tinh): personal income tax, one-time social insurance, household vs company tax. - [Register](https://lawgical.vn/register): free account, unlimited for the first 7 days, then 8 lookups a day (up to 50 in any 30 days), no card. - [Dashboard](https://lawgical.vn/dashboard): plan, quota and upgrade. ## Optional - [Privacy policy](https://lawgical.vn/privacy): what is stored and what is not. - [Terms](https://lawgical.vn/terms): terms of use. - [Support](https://lawgical.vn/support): how to get help. ## Disclaimer Lawgical is a lookup/search tool, not a substitute for a licensed lawyer. AI-generated answers can be wrong. Always cross-check against the primary text and consult a qualified lawyer before acting on legal conclusions. ## Contact - [Email support](mailto:vuongnguyen710@gmail.com): vuongnguyen710@gmail.com