Skip to content

Latest commit

 

History

History
176 lines (129 loc) · 3.65 KB

File metadata and controls

176 lines (129 loc) · 3.65 KB

Account Management

This guide covers how to manage your Origin Quantum account through the MCP server.

Overview

The QPanda3 Runtime MCP Server provides tools for managing your Origin Quantum account authentication. The server uses session-based authentication, meaning credentials are maintained for the duration of the session.

Available Tools

Tool Description
setup_origin_quantum_account_tool Configure account credentials
list_saved_accounts_tool List session account information
active_account_info_tool Get current active account details

Setting Up Your Account

Using Environment Variables (Recommended)

The easiest way to configure your account is through environment variables:

export QPANDA3_API_KEY="your_api_key"
export QPANDA3_SERVER_URL="https://your_server:8080"

Then simply call the setup tool without arguments:

result = await setup_origin_quantum_account_tool()

Using Direct Credentials

You can also provide credentials directly:

result = await setup_origin_quantum_account_tool(
    api_key="your_api_key",
    server_url="https://your_server:8080"
)

Using a Configuration File

Create a config.yml file:

api_key: 'your_api_key_here'
server_url: 'https://your_server_url_here'

Then reference it:

result = await setup_origin_quantum_account_tool(
    config_path="./config.yml"
)

Checking Account Status

List Saved Accounts

accounts = await list_saved_accounts_tool()
print(accounts)

Example output:

{
  "status": "success",
  "accounts": [
    {
      "name": "current_session",
      "channel": "qcloud",
      "connected": true
    }
  ],
  "message": "QPanda3 Runtime uses session-based authentication"
}

Get Active Account Info

info = await active_account_info_tool()
print(info)

Example output:

{
  "status": "success",
  "account": {
    "channel": "qcloud",
    "connected": true,
    "server_url": "https://your_server:8080"
  }
}

Channel

The server uses the qcloud channel, which connects to Origin Quantum's cloud platform.

Error Handling

Common Errors

No credentials provided:

{
  "status": "error",
  "message": "No credentials provided. Please provide api_key and server_url..."
}

Authentication failed:

{
  "status": "error",
  "message": "Failed to setup account: Authentication failed..."
}

Handling Errors

result = await setup_origin_quantum_account_tool(
    api_key="your_key",
    server_url="https://your_server"
)

if result["status"] == "error":
    print(f"Error: {result['message']}")
else:
    print(f"Connected! Available devices: {result['available_devices']}")

Best Practices

  1. Use environment variables for credentials in production
  2. Never hardcode credentials in your source code
  3. Use the qcloud channel for all workloads
  4. Verify connection after setting up the account
  5. Check available devices to ensure the connection is working

Example Workflow

# 1. Set up account
result = await setup_origin_quantum_account_tool(
    api_key="your_key",
    server_url="https://your_server"
)

if result["status"] != "success":
    raise Exception(f"Failed to connect: {result['message']}")

print(f"Connected to {result['channel']} channel")
print(f"Available devices: {result['available_devices']}")

# 2. Verify connection
info = await active_account_info_tool()
print(f"Active account: {info['account']['channel']}")

# 3. List devices to verify access
devices = await list_qpu_devices_tool()
print(f"Found {devices['total_devices']} devices")