# Connect Smart365Guide to AI clients

Endpoint: **https://www.smart365guide.com/api/v1/asdk/mcp**

Industry blueprint access for delegated bearer clients is described in
[Industry modules](./industry-modules.md). Each module requires an explicit
platform assignment for the customer application; existing OAuth scope is unchanged.

Transport: **Streamable HTTP**, stateless JSON responses over POST. An ordinary GET
returns 405; this is not a legacy SSE `/sse` service. A model and a client are
different: the client must support the transport, authentication and tool calls.
Changing the chatbot's model does not automatically register an external agent.

## Connection matrix

| Client | Connection | Authority |
| --- | --- | --- |
| ChatGPT custom MCP connection | Remote OAuth, where enabled by plan/settings | Four read-only ASDK tools; selected applications only |
| Claude remote connector / Claude Code | OAuth-capable Streamable HTTP client | Same selected-app read-only grant |
| Codex CLI | Remote URL and private bearer environment variable | Existing delegated Network key; actions retain provider grants |
| Qwen Code | `httpUrl` with bearer header, or stdio bridge | Existing delegated Network key |
| Claude Desktop / other stdio clients | Downloaded Node bridge | Existing delegated Network key |
| Qwen-Agent | MCP process in `function_list` | Same bridge; model/API configured separately |
| Other vendors / local models | Compatible MCP host or explicit tool adapter | Determined by granted credentials and host permissions |

Protocol/bridge integration tests run against real HTTP and stdio MCP transports.
Native ChatGPT, Claude and Qwen account sessions have not been executed by those
tests. Their plan availability, organization policy, client version, tool approval
UI and browser-control support must be validated in your own environment.

## Before connecting

Register the application, enable Agent integration and Guide, install the browser
SDK for browser workflows, demonstrate/review/publish at least one workflow, and
verify that the intended user has access. Use `/dashboard/asdk` for real status.
A URL, discovery document or browser SDK license is not a delegated agent login.

## ChatGPT: remote OAuth

Where your account permits custom remote MCP connections, open the app/connector
or developer connection settings, add the endpoint above and select OAuth. UI
labels and availability vary by account and product version.

1. The client discovers the authorization server and registers its exact redirect
   URI. It uses an authorization code with **S256 PKCE**.
2. Sign in to Smart365Guide through its ordinary supported login flow.
3. Review the self-reported client name and return host. The name is not verified
   proof of the vendor. Select only the applications you intend to share.
4. Approve **read-only guidance**. The browser returns to the registered client.
5. List tools and call `asdk_list_applications`. Confirm the selected apps only.

No Google OAuth client ID/secret or website password should be pasted into the
connector. Google's existing website login is separate from Smart365Guide's MCP
OAuth authorization server.

Public metadata:

```text
https://www.smart365guide.com/.well-known/oauth-authorization-server
https://www.smart365guide.com/.well-known/oauth-protected-resource/api/v1/asdk/mcp
```

The root `/.well-known/oauth-protected-resource` also describes this resource.
An unauthenticated POST returns 401 with a `WWW-Authenticate` metadata challenge.
OAuth supports dynamic registration of public or secret-authenticated clients,
exact HTTPS redirects (HTTP only for loopback), authorization code, S256, resource
binding, one-use short-lived codes, expiring access tokens, rotating refresh tokens
and revocation. Reusing a consumed refresh token revokes its grant family; reconnect after a replay error. The only current OAuth scope is **`asdk:read`**.

OAuth access does not advertise backend execution tools, supply a browser or
approve a transaction. Use **ASDK setup → Connected AI clients** to revoke the
grant. Revocation is checked on each request, including already connected clients.

## Claude

For a Claude product supporting remote OAuth MCP connections, follow the same
endpoint/consent flow. Check that your organization permits the connection.

For a compatible Claude Code version:

```sh
claude mcp add --transport http smart365guide-asdk "https://www.smart365guide.com/api/v1/asdk/mcp"
```

Restart or open its MCP management/authentication view and complete OAuth. Verify
the installed version's `claude mcp add --help`; do not infer that every Claude
surface has the same connection settings. Desktop clients that launch processes
can use the stdio configuration below instead.

## Codex CLI: bearer key

Create a delegated Network agent key in ASDK setup. Set `S365_NETWORK_KEY` in the
private environment that launches Codex, then run:

```sh
codex mcp add smart365guide-asdk \
  --url "https://www.smart365guide.com/api/v1/asdk/mcp" \
  --bearer-token-env-var S365_NETWORK_KEY
```

Equivalent TOML, using one method only:

```toml
[mcp_servers.smart365guide_asdk]
url = "https://www.smart365guide.com/api/v1/asdk/mcp"
bearer_token_env_var = "S365_NETWORK_KEY"
```

Restart the client. The key is account/company scoped, expires after 30 days and
can be revoked in the Network Console. Choosing an app ID narrows a query; it does
not turn this key into the narrower OAuth selected-app boundary.

## Qwen Code: remote HTTP

Qwen Code's official documentation uses `httpUrl` for Streamable HTTP and `url`
for legacy SSE. Put this in user `~/.qwen/settings.json` or project
`.qwen/settings.json` while keeping the key in the launching environment:

```json
{
  "mcpServers": {
    "smart365guide": {
      "httpUrl": "https://www.smart365guide.com/api/v1/asdk/mcp",
      "headers": { "Authorization": "Bearer ${S365_NETWORK_KEY}" }
    }
  }
}
```

Qwen Code documents environment expansion; verify it in the installed version.
Restart and open `/mcp` to inspect tool discovery. Do not enable unconditional
tool trust or bypass the client's action approvals merely to connect this server.
Qwen's web chat and the Qwen model weights are not automatically MCP clients.

Primary client reference retrieved during implementation:
https://github.com/QwenLM/qwen-code/blob/main/docs/users/features/mcp.md

## Stdio bridge: Claude Desktop and other process-based clients

Download the current integration ZIP. Install dependencies from `server-agent/`:

```sh
cd /absolute/path/to/server-agent
npm install
```

In the client's supported MCP configuration:

```json
{
  "mcpServers": {
    "smart365guide": {
      "command": "/ABSOLUTE/PATH/TO/node",
      "args": ["/ABSOLUTE/PATH/TO/server-agent/mcp-bridge.mjs"],
      "env": {
        "S365_NETWORK_KEY": "YOUR_DELEGATED_AGENT_KEY",
        "S365_MCP_URL": "https://www.smart365guide.com/api/v1/asdk/mcp"
      }
    }
  }
}
```

Replace placeholders privately. GUI apps often do not inherit shell variables.
If the client requires a literal key in user configuration, protect that file and
never commit/share it. If using a secret launcher, omit the `env` key override and
let the launched process inherit the private variable. JSON placeholder expansion
is client-specific; a literal `${S365_NETWORK_KEY}` is not universally expanded.

The bridge validates HTTPS (HTTP only for loopback development), forwards tool
discovery and calls, keeps stdout for MCP framing and uses sanitized stderr errors.
It never executes a local shell from tool arguments. Set optional `S365_LANGUAGE`
in its private environment for an `Accept-Language` preference.

## Qwen-Agent Python example

Install the MCP-enabled Qwen-Agent package according to its current official
instructions, and install the Node bridge dependency above. Configure a supported
tool-calling Qwen model/provider separately. Then attach the bridge:

```python
import os
from qwen_agent.agents import Assistant

agent = Assistant(
    llm={"model": os.environ["QWEN_MODEL"]},
    system_message="Use published guidance, preserve field values, and ask for missing permissions.",
    function_list=[{"mcpServers": {"smart365guide": {
        "command": "/ABSOLUTE/PATH/TO/node",
        "args": ["/ABSOLUTE/PATH/TO/server-agent/mcp-bridge.mjs"],
        "env": {"S365_NETWORK_KEY": os.environ["S365_NETWORK_KEY"]}
    }}}]
)
```

Do not print the function configuration because it contains the key in memory.
Provider credentials belong in its private runtime. MCP attaches tools; it does
not install a model, grant browser access or make an arbitrary model tool-capable.
The official Qwen-Agent MCP example establishes this configuration shape:
https://github.com/QwenLM/Qwen-Agent/blob/main/examples/assistant_mcp_sqlite_bot.py

## Test prompt and expected result

> List my authorized applications. Find published guidance for APP_ID and the
> goal “invite a teammate”. Read the matching workflow and relevant field rules.
> Explain the path in my requested language, preserving selectors and values.
> If authorized browser controls are available, check the current page and roles
> before following a permitted path, then confirm the saved result. If tools,
> guidance, approval or permissions are missing, report what is needed.

OAuth lists `asdk_list_applications`, `asdk_search_workflows`, `asdk_get_workflow`
and `asdk_get_field_options`. All return guidance rather than execution proof.
Bearer keys can additionally advertise search/inspect/execute/verify capability
tools. Those backend tools still require explicit provider/user grants and checks.

## Live observed context

Delegated bearer clients can additionally call `asdk_get_site_context` with an
accessible `appId` and an approved route. The company must enable SDK knowledge
and use of observations in guidance. Results include an observed revision, reception
time and a staleness flag; they do not execute an action or replace an approved
workflow. Existing published-guidance OAuth grants are not expanded by this tool.
See [live site guidance](live-site-guide.md).

## Troubleshooting

| Symptom | Check |
| --- | --- |
| 401 | Correct key/token kind; expiry/revocation; OAuth discovery; private runtime environment |
| 403 | Current account membership, company package, application status and guide feature |
| GET gives 405 | Expected for this POST-based stateless service; configure Streamable HTTP |
| No workflows | Correct app ID, owner-published status and package permissions |
| OAuth redirect rejected | Exact registered URI, HTTPS/loopback rule, state and S256 parameters; restart the connection |
| OAuth tools cannot execute | Deliberate read-only scope; browser controls or separately granted backend integration are required |
| Qwen HTTP fails | Use `httpUrl`, not legacy SSE `url`; verify environment expansion |
| Desktop process fails | Absolute Node/script paths, installed dependency and actual GUI process environment |
| TLS error in a managed environment | Configure its legitimate CA/proxy trust; do not disable certificate checks |
| Model narrates success without action | Require authorized execution and independent saved-state evidence |

Official OpenAI/Claude documentation URLs were blocked by this workspace's network
policy during implementation. Their exact current UI labels and account eligibility
are not presented as verified. The authentication implementation follows MCP OAuth
discovery and code/PKCE conventions and is tested independently of vendor accounts.
