Documentations

Lawgical Documentations

Lawgical is an MCP server: connect it to Claude or ChatGPT, and your assistant can look up 150,000+ Vietnamese legal documents, cited down to the Điều. This page is the technical reference — installation, the endpoints, authentication, and the errors you might hit.

Installation

Everything below assumes you've connected Lawgical first. The only way in is OAuth — no API key, nothing to paste anywhere. You add Lawgical as a connector in your AI app, hit Connect, sign in, and authorize.

Server URL (Remote MCP)
https://legal.lawgical.vn/mcp

Most apps self-register (DCR, RFC 7591), so leave the OAuth Client ID field blank. If an app can't do that, or errors on login, fill in lawgical-mcp. No app needs a Client Secret — this is a public client using PKCE.

  • Supported: Claude.ai (web & mobile), Claude Desktop, ChatGPT (web & mobile, Developer mode), ChatGPT Desktop.
  • Not yet supported: config-file clients, such as Gemini CLI, Cursor, VS Code.
Step-by-step guide, with video

Quickstart

Once connected (previous section), open a new chat and ask a legal question directly. The video below (same one on the homepage) shows Lawgical working live inside Claude.

Or just try it — ask something like:

Luật Doanh nghiệp 2020 quy định gì về vốn điều lệ?

If it's connected, you'll see a line like "Called tool" or "Talked to lawgical" above the answer — that's the assistant calling search_legal_docs and reading the real text, instead of answering from memory. The answer should cite a specific Điều number.

Not seeing that line, or getting an answer with no citations? Check Common errors below. For more real questions answered with full citations, see the examples page.

MCP Documentation

Lawgical exposes 6 endpoints at https://legal.lawgical.vn/mcp. You never call them by name — ask normally and the AI picks whichever endpoint it needs.

Every successful call counts 1 query against your daily quota, except get_account_status(), which is always free. A miss or an error costs nothing.

search_legal_docs(keywords)1 query

Keyword search across the whole corpus. Call this first for an open-ended question.

Parameters
  • keywords Keywords, Vietnamese or English. Vietnamese matches noticeably better.
Returns

A ranked list of titles with excerpts. A hit matching a reference number is usually a document CITING that number, not the document itself — read the titles before picking one.

get_summary(query)1 query

Gets a document's table of contents (Chương, Mục, Điều) without the full text. Call this first on a long law to find the right Điều without paying for the whole body.

Parameters
  • query Either a reference number OR a title — never both in one call.
Returns

The document's Chương / Mục / Điều headings.

get_document(query)1 query

Full text of one document.

Parameters
  • query A reference number (e.g. "20/2023/QH15"), a title, or a doc id.
Returns

The document's full text. Check the reference number at the top of the result against what you asked for, and check its legal-force status, before quoting it.

check_compliance(question)1 query

Feed it a question, get back relevant excerpts to read and judge yourself. It does not decide compliance — you do.

Parameters
  • question What you're trying to do, written as a sentence, Vietnamese or English.
Returns

Raw excerpts from related documents. Can include off-topic noise — judge each one on its own.

get_laws(tinh_trang, keyword, limit, offset)1 query

Browses Luật (National Assembly Acts) specifically, without the implementing Nghị định or Thông tư mixed in.

Parameters
  • tinh_trang Filter by legal-force status. Defaults to "Còn hiệu lực" (in force); pass "" for every status.
  • keyword Substring to filter titles by. Leave empty to see everything.
  • limit Max results. Defaults to 50, capped at 200.
  • offset Pagination offset. Defaults to 0.
Returns

The list of Luật matching the filter.

get_account_status()Free

Your plan, queries used and remaining today, renewal date, and an upgrade link.

Parameters

None.

Returns

Current plan, today's quota, expiry or renewal date, and a payment link.

Authentication

Lawgical runs two separate authentication systems over one User table: the website session (NextAuth, JWT session cookie) and the MCP connector for AI apps (OAuth 2.1 authorization code + PKCE). Neither ever exposes your password to a third-party app.

Signing in to Lawgical

Open lawgical.vn/login
Google OIDC (prompt=select_account) or email + password (bcrypt)
JWT session cookie issued

Connecting an AI app (OAuth 2.1 + PKCE)

  1. 1
    AI app Your browser
    You hit “Connect” — the app calls /authorize; the browser is sent to lawgical.vn with a short-lived request id (the PKCE challenge stays parked server-side)
  2. 2
    Your browser
    Sign in with Google OIDC or credentials — the session is a first-party JWT cookie; credentials never pass through the AI app
  3. 3
    Lawgical Your browser
    Dynamically-registered client (DCR)? A consent screen shows the client name and redirect host. Pre-registered clients (Claude/ChatGPT — host-locked redirect URIs) auto-approve
  4. 4
    Your browser Lawgical
    You approve — a single-use, short-TTL authorization code bound to the PKCE challenge is issued
  5. 5
    Lawgical AI app
    The app redeems the code at /token with its PKCE verifier → access token (30 days) + refresh token (90 days)
  6. 6
    AI app
    Tokens are stored hashed server-side; every refresh rotates the pair (RFC 9700), scoped per authorization — one device never retires another's tokens

Security properties

  • Google OIDC always sends prompt=select_account, so an existing Google session in the browser is never silently reused for the wrong account.
  • Password logins are rate-limited per IP and per email before the password is even checked; passwords are stored only as bcrypt hashes.
  • Authorization codes are single-use and PKCE-bound; tokens are random bearers, never your password — revoking one app's connection leaves every other untouched.

For integrators

Only one way in: OAuth with PKCE, no client secret. The server supports dynamic client registration (DCR), so most apps need nothing beyond the Server URL. Apps that can't do DCR use the fixed Client ID lawgical-mcp. No API key is ever issued, not even on the Paid plan.

Billing

Free

20 queries a day, no card needed. Resets at 00:00 Vietnam time.

Paid

99.000đ per user per month, unlimited queries.

Payments run through PayOS (VietQR) and auto-renew each cycle unless you cancel. Cancel any time from the dashboard — access stays active through the end of the paid cycle; we don't yet refund unused time. Call get_account_status() mid-chat to check what's left — that call never costs a query.

Common errors

Your session has expired. You can reconnect to re-authorize.

Reconnect the Lawgical connector in your AI app. If this comes back after only a few hours, please let us know — a session normally doesn't expire that fast.

Authorization with Lawgical failed

This also covers a connector that connects but shows no tools. It's usually pointed at an old Lawgical Server URL. Delete that connector and add it again from scratch — reconnecting the old one never works, because the token it holds is bound to whatever URL it was first configured with.

Không thể tra cứu: đã dùng hết 20/20 lượt tra cứu hôm nay.

The Free plan's daily quota is used up. It resets at 00:00 Vietnam time, or upgrade to Paid to remove the limit. Call get_account_status() for the exact number — that call is always free.

No tools show up after connecting

Double-check the Server URL was entered exactly as https://legal.lawgical.vn/mcp. A single wrong character still lets the connector say "connected" while leaving it with no tools to call.

FAQ

Do I need an API key?

No. Lawgical authenticates only through OAuth. No API key, no static bearer token, nothing to paste into a config file.

Does Lawgical store my questions?

The server logs some queries (search terms, requested doc IDs, whether anything was found) to catch coverage gaps in the corpus, but never ties them to your account or identity. Full detail is on the privacy page.

Can I cancel the Paid plan?

Yes, cancel any time from the dashboard. Access stays active through the end of the paid cycle; we don't yet offer refunds for unused time.

Why didn't I get a verification email?

Check spam first. If it still hasn't shown up after a few minutes, email us with the address you signed up with.

Can Lawgical's answers replace legal advice?

No. Lawgical is a lookup tool, not a lawyer. Always cross-check against the primary text and consult a licensed lawyer before acting on a legal conclusion.

Does it work with Gemini CLI, Cursor, or VS Code?

Not yet. Those tools authenticate with a header credential, which Lawgical dropped when it moved entirely to OAuth. Only Claude and ChatGPT (web, desktop, mobile) can connect right now.

Don't see your question here? Email us, or check the Support page.