- Home
- Plugins
- Tools & Capabilities
- aiqicha-dsh-mcp-legal-oauth
aiqicha-dsh-mcp-legal-oauth
baidu/aiqicha-dsh-mcp-legal-oauth
Connect an Aiqicha account to DeepSeek Harness over OAuth 2.1 (PKCE) to search statutes, regulations and court cases, draft case analyses and legal documents, and verify cited case numbers and articles through the official Aiqicha remote MCP server.
Install
dsh plugin --profile web add github:baidu/aiqicha-dsh-mcp-legal-oauthREADME
aiqicha-dsh-mcp-legal-oauth
A DeepSeek Harness (DSH) plugin that connects the "Aiqicha Legal Expert" MCP service to DSH through OAuth sign-in.
Once connected, the model can search laws, regulations and specific articles, and judgments and cases. It can also draft case analyses and legal documents from the facts of a case, and verify the case numbers, regulations and articles cited in a text. The service endpoint is https://agent.aiqicha.com/mcp/aqc-legal. Generated content is for reference only and is not legal advice.
How it works
The plugin uses the OAuth 2.0 authorization code flow with PKCE (S256 only). The client obtains its client_id through dynamic client registration (RFC 7591), so no secret has to be applied for in advance.
- When the plugin activates without a valid authorization, it starts authorization and opens the browser automatically. You can also have the model call
aiqicha_legal_connect, which returns an authorization URL. - Open the URL in a browser, sign in to your Aiqicha account and approve access. The browser is redirected back to a callback port on
127.0.0.1. - The plugin exchanges the code for tokens and registers the Aiqicha MCP service with the DSH MCP manager. The model can then use its tools.
- Before the access token expires, the plugin replaces it with the refresh token automatically.
The business, legal, and tender plugins share one Aiqicha authorization within a DSH profile when using their default connection settings. Authorize from any plugin and the other enabled plugins connect automatically. Only one authorization is started when several plugins activate at the same time. Forced authorization updates the shared account. Disconnecting clears the shared authorization. After upgrading, authorize once in the current profile. Custom connections continue to require separate authorization.
Tokens are stored only in the DSH credential provider. They never appear in logs, tool results or this repository.
Tools
| Tool | Purpose |
|---|---|
aiqicha_legal_connect | Starts authorization and returns the authorization URL. Does nothing if already connected; pass force: true to authorize again. |
aiqicha_legal_status | Shows the connection state: disconnected, pending, connected or reauth-required. |
aiqicha_legal_disconnect | Revokes the tokens (best effort), unregisters the MCP service and clears local credentials. |
reauth-required means the refresh token is no longer valid. Call aiqicha_legal_connect again.
Configuration
Every option has a default, so you normally do not need to change anything. Override them in the profile patch when needed.
| Option | Default | Description |
|---|---|---|
issuer | https://agent.aiqicha.com | OAuth authorization server |
resource | https://agent.aiqicha.com/mcp/aqc-legal | MCP endpoint |
clientName | DeepSeek Harness - 爱企查 MCP | Client name reported during dynamic registration |
scope | mcp | Requested scope |
serverName | aiqicha_legal | Service name registered with the MCP manager |
tokenRef | AIQICHA_LEGAL_MCP_ACCESS_TOKEN | Access token reference prefix in standalone mode |
callbackPort | 0 | Local callback port. 0 prefers the previous port and falls back to a random port. A nonzero value uses standalone authorization |
openBrowser | true | Whether to try to open the browser when authorization starts |
autoConnect | true | Start authorization and open the browser automatically when the plugin activates without a valid grant; set to false to disable |
authTimeoutMs | 300000 | Maximum time to wait for the user to authorize |
refreshSkewSec | 120 | How many seconds before expiry the token is refreshed |
requestTimeoutMs | 15000 | Timeout of a single network request |
Usage
The package is published to npm as aiqicha-dsh-mcp-legal-oauth. Install it into a DSH profile; a global npm install -g is not picked up by DSH.
Install from npm (recommended)
dsh plugin --profile web add aiqicha-dsh-mcp-legal-oauth
Restart DSH afterwards. For the desktop client, fully quit it first and use the desktop profile:
dsh plugin --profile desktop add aiqicha-dsh-mcp-legal-oauth
The package declares dsh.bundle, so the CLI registers it in dsh.profile.bundles of ~/.dsh/profiles/<profile>/package.json. If it does not show up there, add "aiqicha-dsh-mcp-legal-oauth" to that array yourself and restart.
Install from GitHub
dsh plugin --profile web add github:baidu/aiqicha-dsh-mcp-legal-oauth
Install from a local checkout
Clone the repository. No dependency installation is required: the runtime code statically imports only node: built-ins, and @deepseek-ai/schemastery is an optional dependency used for configuration validation and the settings form. Without any node_modules the plugin still loads and registers its tools, and configuration falls back to the built-in defaults (autoConnect, openBrowser, issuer, … can still be overridden in a profile patch).
git clone https://github.com/baidu/aiqicha-dsh-mcp-legal-oauth.git
dsh plugin --profile web add "link:$(pwd)/aiqicha-dsh-mcp-legal-oauth"
On Windows PowerShell, use "file:$((Get-Location).Path)" instead of the link: form. In the desktop client you can also click "Add plugin" on the Plugins page and choose the repository directory.
Without the CLI, write a patch file whose name is the absolute path of lib/index.js, and pass it with --patch when starting DSH:
# my.patch.yml
- insert:
- id: aiqicha-legal
name: /absolute/path/to/aiqicha-dsh-mcp-legal-oauth/lib/index.js
dsh web --patch ./my.patch.yml
Run npm install inside the checkout only when you want the settings form and typed validation.
After switching between a local directory and a package installation, fully quit and restart DSH: it may still resolve the old path. Do not keep both a link: installation and a package installation.
Verify
On activation the plugin opens the authorization page automatically and the state is pending. Ask the model to call aiqicha_legal_status; the state becomes connected after authorization. If the page did not open, call aiqicha_legal_connect to get the authorization URL.
Upgrade and uninstall
dsh plugin --profile web update aiqicha-dsh-mcp-legal-oauth
dsh plugin --profile web remove aiqicha-dsh-mcp-legal-oauth
After removing a package that was registered in dsh.profile.bundles, also drop it from that array.
Security
- Only
httpsURLs are accepted, except loopback addresses. The authorization server metadata and every endpoint are validated. - The callback server listens on
127.0.0.1only and acceptsGET /callbackonly. A request with a mismatchedstateis rejected and does not consume the authorization. - Authorization codes, tokens and PKCE verifiers never appear in logs or error messages.
- A failed revocation does not block local cleanup.
Development
Requires Node.js 20 or later.
npm install
npm test
Tests use the built-in node:test, and the authorization server is simulated locally, so they do not reach the network. They cover PKCE, metadata discovery, callback validation, the full authorization flow, token refresh and rotation, reauth-required, disconnecting, and the absence of sensitive data in logs.
The host @deepseek-ai/dsh requires Node.js 24.9 or later.
License
Apache-2.0. See LICENSE.
Related plugins
archify (deepseek-harness)
tt-a1i/archify
WeKnora (dsh-weknora)
tencent/weknora
next-ai-draw-io (dsh-plugin)
dayuanjiang/next-ai-draw-io
AiToEarn (dsh-plugin-aitoearn)
yikart/aitoearn