@assetlab/mcp-server 1.0.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +174 -112
- package/dist/client.d.ts +11 -0
- package/dist/client.js +53 -0
- package/dist/client.js.map +1 -1
- package/dist/oauth.d.ts +20 -0
- package/dist/oauth.js +331 -0
- package/dist/oauth.js.map +1 -0
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +818 -18
- package/dist/tools.js.map +1 -1
- package/dist/worker.d.ts +19 -0
- package/dist/worker.js +121 -0
- package/dist/worker.js.map +1 -0
- package/package.json +13 -5
package/README.md
CHANGED
|
@@ -1,112 +1,174 @@
|
|
|
1
|
-
# @assetlab/mcp-server
|
|
2
|
-
|
|
3
|
-
Connect [Claude](https://claude.ai) to your [AssetLab](https://assetlab.ca) account via the [Model Context Protocol](https://modelcontextprotocol.io). Ask Claude questions about your assets, work orders, PM schedules, and more — in plain language.
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
- [Node.js](https://nodejs.org) 18 or later
|
|
8
|
-
- An AssetLab account with an API key (create one in **Settings → API Keys**)
|
|
9
|
-
- [Claude Desktop](https://claude.ai/download) or [Claude Code](https://claude.ai/code)
|
|
10
|
-
|
|
11
|
-
## Setup
|
|
12
|
-
|
|
13
|
-
### Claude Desktop
|
|
14
|
-
|
|
15
|
-
1. Open your Claude Desktop config file:
|
|
16
|
-
- **Mac:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
17
|
-
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
18
|
-
|
|
19
|
-
2. Add the following to the `mcpServers` object (replace `al_live_...` with your API key):
|
|
20
|
-
|
|
21
|
-
```json
|
|
22
|
-
{
|
|
23
|
-
"mcpServers": {
|
|
24
|
-
"assetlab": {
|
|
25
|
-
"command": "npx",
|
|
26
|
-
"args": ["-y", "@assetlab/mcp-server"],
|
|
27
|
-
"env": {
|
|
28
|
-
"ASSETLAB_API_KEY": "al_live_...",
|
|
29
|
-
"ASSETLAB_API_URL": "your-api-url"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
> **Tip:** The easiest way to get this config is to click **Copy Claude Config** directly on your API key in **AssetLab Settings → API Keys** — it pre-fills your key and API URL automatically.
|
|
37
|
-
|
|
38
|
-
3. Restart Claude Desktop. You should see the AssetLab tools available.
|
|
39
|
-
|
|
40
|
-
### Claude Code
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
claude mcp add assetlab npx @assetlab/mcp-server \
|
|
44
|
-
-e ASSETLAB_API_KEY=al_live_... \
|
|
45
|
-
-e ASSETLAB_API_URL=your-api-url
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Example prompts
|
|
49
|
-
|
|
50
|
-
Once connected, you can ask Claude things like:
|
|
51
|
-
|
|
52
|
-
- *"Show me all overdue work orders"*
|
|
53
|
-
- *"List critical assets at Site A"*
|
|
54
|
-
- *"What PM schedules are due this month?"*
|
|
55
|
-
- *"Summarize the current state of our facilities"*
|
|
56
|
-
- *"Which projects are at risk or delayed?"*
|
|
57
|
-
- *"Show me all assets linked to the HVAC system in Building 3"*
|
|
58
|
-
- *"List open corrective work orders at all sites"*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
|
67
|
-
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
|
90
|
-
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
# @assetlab/mcp-server
|
|
2
|
+
|
|
3
|
+
Connect [Claude](https://claude.ai) to your [AssetLab](https://assetlab.ca) account via the [Model Context Protocol](https://modelcontextprotocol.io). Ask Claude questions about your assets, work orders, PM schedules, and more — in plain language.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- [Node.js](https://nodejs.org) 18 or later
|
|
8
|
+
- An AssetLab account with an API key (create one in **Settings → API Keys**)
|
|
9
|
+
- [Claude Desktop](https://claude.ai/download) or [Claude Code](https://claude.ai/code)
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
### Claude Desktop
|
|
14
|
+
|
|
15
|
+
1. Open your Claude Desktop config file:
|
|
16
|
+
- **Mac:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
17
|
+
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
18
|
+
|
|
19
|
+
2. Add the following to the `mcpServers` object (replace `al_live_...` with your API key):
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"assetlab": {
|
|
25
|
+
"command": "npx",
|
|
26
|
+
"args": ["-y", "@assetlab/mcp-server"],
|
|
27
|
+
"env": {
|
|
28
|
+
"ASSETLAB_API_KEY": "al_live_...",
|
|
29
|
+
"ASSETLAB_API_URL": "your-api-url"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
> **Tip:** The easiest way to get this config is to click **Copy Claude Config** directly on your API key in **AssetLab Settings → API Keys** — it pre-fills your key and API URL automatically.
|
|
37
|
+
|
|
38
|
+
3. Restart Claude Desktop. You should see the AssetLab tools available.
|
|
39
|
+
|
|
40
|
+
### Claude Code
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
claude mcp add assetlab npx @assetlab/mcp-server \
|
|
44
|
+
-e ASSETLAB_API_KEY=al_live_... \
|
|
45
|
+
-e ASSETLAB_API_URL=your-api-url
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Example prompts
|
|
49
|
+
|
|
50
|
+
Once connected, you can ask Claude things like:
|
|
51
|
+
|
|
52
|
+
- *"Show me all overdue work orders"*
|
|
53
|
+
- *"List critical assets at Site A"*
|
|
54
|
+
- *"What PM schedules are due this month?"*
|
|
55
|
+
- *"Summarize the current state of our facilities"*
|
|
56
|
+
- *"Which projects are at risk or delayed?"*
|
|
57
|
+
- *"Show me all assets linked to the HVAC system in Building 3"*
|
|
58
|
+
- *"List open corrective work orders at all sites"*
|
|
59
|
+
- *"What's the total cost history for Asset X?"*
|
|
60
|
+
- *"Show me all project milestones that are at risk"*
|
|
61
|
+
- *"What's the FCI trend for Site A over the past year?"*
|
|
62
|
+
- *"List all replacement plans due in 2027"*
|
|
63
|
+
|
|
64
|
+
## Available tools
|
|
65
|
+
|
|
66
|
+
| Tool | Description |
|
|
67
|
+
|------|-------------|
|
|
68
|
+
| `list_assets` | List assets with filters for site, building, system, and search |
|
|
69
|
+
| `get_asset` | Get full details for a specific asset |
|
|
70
|
+
| `list_work_orders` | List work orders filtered by status, priority, type, or site |
|
|
71
|
+
| `get_work_order` | Get full details for a specific work order |
|
|
72
|
+
| `list_sites` | List all sites in your organization |
|
|
73
|
+
| `get_site` | Get details for a specific site |
|
|
74
|
+
| `list_buildings` | List buildings, optionally filtered by site |
|
|
75
|
+
| `list_locations` | List rooms and areas, optionally filtered by building |
|
|
76
|
+
| `list_systems` | List systems (HVAC, plumbing, electrical, etc.) |
|
|
77
|
+
| `list_system_groups` | List system groups |
|
|
78
|
+
| `list_system_classes` | List top-level system classifications |
|
|
79
|
+
| `list_pm_schedules` | List PM schedules filtered by status, frequency, or site |
|
|
80
|
+
| `get_pm_schedule` | Get a PM schedule including tasks and linked assets |
|
|
81
|
+
| `list_pm_templates` | List reusable PM templates |
|
|
82
|
+
| `list_projects` | List capital projects filtered by status or health |
|
|
83
|
+
| `get_project` | Get project details including budget and progress |
|
|
84
|
+
| `list_contracts` | List vendor contracts |
|
|
85
|
+
| `list_compliance_items` | List compliance/regulatory items |
|
|
86
|
+
| `get_compliance_item` | Get a compliance item with linked PM schedules |
|
|
87
|
+
| `get_dashboard_summary` | Get aggregated stats across assets, work orders, and sites |
|
|
88
|
+
| `list_budgets` | List annual funding budgets by year, site, building, or funding source |
|
|
89
|
+
| `get_budget` | Get a single annual funding budget |
|
|
90
|
+
| `list_asset_comments` | List comments on assets, filterable by asset |
|
|
91
|
+
| `get_asset_comment` | Get a single asset comment |
|
|
92
|
+
| `list_asset_costs` | List asset cost records (repairs, PM, operations, replacements) |
|
|
93
|
+
| `get_asset_cost` | Get a single asset cost record with related names |
|
|
94
|
+
| `list_asset_replacement_plans` | List asset replacement plans for lifecycle planning |
|
|
95
|
+
| `get_asset_replacement_plan` | Get a single replacement plan |
|
|
96
|
+
| `list_asset_risk_history` | List risk assessment history for assets |
|
|
97
|
+
| `get_asset_risk_history_entry` | Get a single risk history entry |
|
|
98
|
+
| `list_work_order_comments` | List comments on work orders |
|
|
99
|
+
| `get_work_order_comment` | Get a single work order comment |
|
|
100
|
+
| `list_project_tasks` | List project tasks with status, priority, cost tracking |
|
|
101
|
+
| `get_project_task` | Get a single project task |
|
|
102
|
+
| `list_project_milestones` | List project milestones |
|
|
103
|
+
| `get_project_milestone` | Get a single milestone |
|
|
104
|
+
| `list_project_phases` | List project phases |
|
|
105
|
+
| `get_project_phase` | Get a single phase |
|
|
106
|
+
| `list_project_budget_items` | List project budget line items by category |
|
|
107
|
+
| `get_project_budget_item` | Get a single budget item |
|
|
108
|
+
| `list_project_time_entries` | List time entries for project labor tracking |
|
|
109
|
+
| `get_project_time_entry` | Get a single time entry |
|
|
110
|
+
| `list_project_comments` | List comments on projects (threaded) |
|
|
111
|
+
| `get_project_comment` | Get a single project comment |
|
|
112
|
+
| `list_compliance_records` | List compliance check completion records |
|
|
113
|
+
| `get_compliance_record` | Get a single compliance record |
|
|
114
|
+
| `list_site_fci_history` | List Facility Condition Index history for sites |
|
|
115
|
+
| `get_site_fci_history_entry` | Get a single FCI history entry |
|
|
116
|
+
| `list_dashboard_snapshots` | List monthly aggregate dashboard snapshots |
|
|
117
|
+
| `get_dashboard_snapshot` | Get a single dashboard snapshot |
|
|
118
|
+
| `list_vendor_site_assignments` | List vendor-to-site service mappings |
|
|
119
|
+
| `get_vendor_site_assignment` | Get a single vendor site assignment |
|
|
120
|
+
| `list_contract_sites` | List contract-to-site coverage mappings |
|
|
121
|
+
| `list_custom_field_definitions` | List custom field schemas by entity type |
|
|
122
|
+
| `get_custom_field_definition` | Get a single custom field definition |
|
|
123
|
+
| `list_custom_field_values` | List custom field values by entity or field |
|
|
124
|
+
| `get_custom_field_value` | Get a single custom field value |
|
|
125
|
+
| `list_part_categories` | List part categories |
|
|
126
|
+
| `get_part_category` | Get a single part category |
|
|
127
|
+
|
|
128
|
+
## Scopes
|
|
129
|
+
|
|
130
|
+
API keys use scopes to control what Claude can access. Grant only the scopes you need:
|
|
131
|
+
|
|
132
|
+
| Scope | Access |
|
|
133
|
+
|-------|--------|
|
|
134
|
+
| `assets:read` | Assets |
|
|
135
|
+
| `work_orders:read` | Work orders |
|
|
136
|
+
| `sites:read` | Sites and buildings |
|
|
137
|
+
| `locations:read` | Locations |
|
|
138
|
+
| `systems:read` | Systems, system groups, system classes |
|
|
139
|
+
| `pm_schedules:read` | PM schedules and templates |
|
|
140
|
+
| `projects:read` | Capital projects |
|
|
141
|
+
| `contracts:read` | Vendor contracts |
|
|
142
|
+
| `compliance:read` | Compliance items |
|
|
143
|
+
| `dashboard:read` | Dashboard summary stats |
|
|
144
|
+
| `budgets:read` | Annual funding budgets |
|
|
145
|
+
| `asset_comments:read` | Asset comments |
|
|
146
|
+
| `asset_costs:read` | Asset cost records |
|
|
147
|
+
| `asset_replacement_plans:read` | Asset replacement plans |
|
|
148
|
+
| `asset_risk_history:read` | Asset risk history |
|
|
149
|
+
| `work_order_comments:read` | Work order comments |
|
|
150
|
+
| `project_tasks:read` | Project tasks |
|
|
151
|
+
| `project_milestones:read` | Project milestones |
|
|
152
|
+
| `project_phases:read` | Project phases |
|
|
153
|
+
| `project_budget_items:read` | Project budget items |
|
|
154
|
+
| `project_time_entries:read` | Project time entries |
|
|
155
|
+
| `project_comments:read` | Project comments |
|
|
156
|
+
| `compliance_records:read` | Compliance records |
|
|
157
|
+
| `site_fci_history:read` | Site FCI history |
|
|
158
|
+
| `dashboard_snapshots:read` | Dashboard snapshots |
|
|
159
|
+
| `vendor_site_assignments:read` | Vendor site assignments |
|
|
160
|
+
| `contract_sites:read` | Contract site mappings |
|
|
161
|
+
| `custom_fields:read` | Custom field definitions and values |
|
|
162
|
+
| `part_categories:read` | Part categories |
|
|
163
|
+
| `*:*` | All resources |
|
|
164
|
+
|
|
165
|
+
## Security
|
|
166
|
+
|
|
167
|
+
- The MCP server runs **locally** on your machine via stdio — no network server is exposed
|
|
168
|
+
- Your API key is scoped to your organization only
|
|
169
|
+
- All data access is read-only and logged in AssetLab's audit log
|
|
170
|
+
- API keys can be revoked at any time in **Settings → API Keys**
|
|
171
|
+
|
|
172
|
+
## Support
|
|
173
|
+
|
|
174
|
+
Questions or issues? Email [support@assetlab.ca](mailto:support@assetlab.ca).
|
package/dist/client.d.ts
CHANGED
|
@@ -30,6 +30,17 @@ export declare class AssetLabClient {
|
|
|
30
30
|
constructor(config: AssetLabConfig);
|
|
31
31
|
get<T = Record<string, unknown>>(path: string, params?: Record<string, string | number | undefined>): Promise<T>;
|
|
32
32
|
list<T = Record<string, unknown>>(resource: string, params?: Record<string, string | number | undefined>): Promise<PaginatedResponse<T>>;
|
|
33
|
+
/**
|
|
34
|
+
* Fetch all pages of a paginated resource automatically.
|
|
35
|
+
* Uses per_page=1000 to minimize round-trips, then follows
|
|
36
|
+
* pagination until all rows are collected.
|
|
37
|
+
*/
|
|
38
|
+
listAll<T = Record<string, unknown>>(resource: string, params?: Record<string, string | number | undefined>): Promise<{
|
|
39
|
+
data: T[];
|
|
40
|
+
total: number;
|
|
41
|
+
}>;
|
|
33
42
|
getOne<T = Record<string, unknown>>(resource: string, id: string): Promise<SingleResponse<T>>;
|
|
43
|
+
post<T = Record<string, unknown>>(path: string, body: Record<string, unknown>): Promise<T>;
|
|
44
|
+
create<T = Record<string, unknown>>(resource: string, body: Record<string, unknown>): Promise<SingleResponse<T>>;
|
|
34
45
|
}
|
|
35
46
|
export declare function loadConfig(): AssetLabConfig;
|
package/dist/client.js
CHANGED
|
@@ -66,9 +66,62 @@ export class AssetLabClient {
|
|
|
66
66
|
async list(resource, params) {
|
|
67
67
|
return this.get(`/${resource}`, params);
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Fetch all pages of a paginated resource automatically.
|
|
71
|
+
* Uses per_page=1000 to minimize round-trips, then follows
|
|
72
|
+
* pagination until all rows are collected.
|
|
73
|
+
*/
|
|
74
|
+
async listAll(resource, params) {
|
|
75
|
+
const allData = [];
|
|
76
|
+
let page = 1;
|
|
77
|
+
const perPage = 1000;
|
|
78
|
+
while (true) {
|
|
79
|
+
const result = await this.list(resource, { ...params, page, per_page: perPage });
|
|
80
|
+
allData.push(...result.data);
|
|
81
|
+
if (page >= result.pagination.total_pages)
|
|
82
|
+
break;
|
|
83
|
+
page++;
|
|
84
|
+
}
|
|
85
|
+
return { data: allData, total: allData.length };
|
|
86
|
+
}
|
|
69
87
|
async getOne(resource, id) {
|
|
70
88
|
return this.get(`/${resource}/${id}`);
|
|
71
89
|
}
|
|
90
|
+
async post(path, body) {
|
|
91
|
+
const url = `${this.baseUrl}${path}`;
|
|
92
|
+
const res = await fetch(url, {
|
|
93
|
+
method: 'POST',
|
|
94
|
+
headers: {
|
|
95
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
96
|
+
'Content-Type': 'application/json',
|
|
97
|
+
},
|
|
98
|
+
body: JSON.stringify(body),
|
|
99
|
+
});
|
|
100
|
+
if (!res.ok) {
|
|
101
|
+
const data = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
|
|
102
|
+
const message = data.error || `HTTP ${res.status}`;
|
|
103
|
+
switch (res.status) {
|
|
104
|
+
case 401:
|
|
105
|
+
throw new AssetLabClientError(401, 'Authentication failed. Check your ASSETLAB_API_KEY.');
|
|
106
|
+
case 403:
|
|
107
|
+
throw new AssetLabClientError(403, message.includes('scope')
|
|
108
|
+
? message
|
|
109
|
+
: message.includes('expired')
|
|
110
|
+
? 'API key has expired. Generate a new one in AssetLab Settings > API Keys.'
|
|
111
|
+
: message);
|
|
112
|
+
case 429:
|
|
113
|
+
throw new AssetLabClientError(429, 'Rate limit exceeded. Wait a moment and try again.');
|
|
114
|
+
case 400:
|
|
115
|
+
throw new AssetLabClientError(400, message);
|
|
116
|
+
default:
|
|
117
|
+
throw new AssetLabClientError(res.status, message);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return res.json();
|
|
121
|
+
}
|
|
122
|
+
async create(resource, body) {
|
|
123
|
+
return this.post(`/${resource}`, body);
|
|
124
|
+
}
|
|
72
125
|
}
|
|
73
126
|
export function loadConfig() {
|
|
74
127
|
const apiKey = process.env.ASSETLAB_API_KEY;
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqBH,MA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QAAQ,CAAC,SAAS,CAAC;4BAC3B,CAAC,CAAC,0EAA0E;4BAC5E,CAAC,CAAC,OAAO,CAAC,CAAA;gBAChB,KAAK,GAAG;oBACN,MAAM,IAAI,mBAAmB,CAAC,GAAG,EAAE,mDAAmD,CAAC,CAAA;gBACzF,KAAK,GAAG;oBACN,MAAM,IAAI,mBAAmB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;gBAC7C;oBACE,MAAM,IAAI,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;YACtD,CAAC;QACH,CAAC;QAED,OAAO,GAAG,CAAC,IAAI,EAAgB,CAAA;IACjC,CAAC;IAED,KAAK,CAAC,MAAM,CACV,QAAgB,EAChB,IAA6B;QAE7B,OAAO,IAAI,CAAC,IAAI,CAAoB,IAAI,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAA;IAC3D,CAAC;CACF;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAA;IAC3C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,qDAAqD;YACrD,oDAAoD,CACrD,CAAA;IACH,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAA;IAC3C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,qDAAqD;YACrD,iEAAiE,CAClE,CAAA;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AAC3B,CAAC"}
|
package/dist/oauth.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal OAuth 2.0 Authorization Server for Claude.ai MCP integration.
|
|
3
|
+
*
|
|
4
|
+
* Implements just enough of OAuth 2.0 + PKCE to satisfy Claude.ai's connector flow:
|
|
5
|
+
* 1. Dynamic client registration (RFC 7591)
|
|
6
|
+
* 2. Authorization endpoint (shows "paste your API key" page)
|
|
7
|
+
* 3. Token endpoint (exchanges auth code for access token)
|
|
8
|
+
*
|
|
9
|
+
* The user's AssetLab API key becomes the OAuth access_token, so the existing
|
|
10
|
+
* MCP handler works unchanged (it reads Bearer token from Authorization header).
|
|
11
|
+
*
|
|
12
|
+
* Authorization codes are encrypted with AES-GCM using OAUTH_SECRET — fully
|
|
13
|
+
* stateless, no KV or Durable Objects needed.
|
|
14
|
+
*/
|
|
15
|
+
export declare function protectedResourceMetadata(origin: string): Response;
|
|
16
|
+
export declare function authServerMetadata(origin: string): Response;
|
|
17
|
+
export declare function handleRegister(request: Request): Promise<Response>;
|
|
18
|
+
export declare function handleAuthorizeGet(request: Request): Response;
|
|
19
|
+
export declare function handleAuthorizePost(request: Request, secret: string): Promise<Response>;
|
|
20
|
+
export declare function handleToken(request: Request, secret: string): Promise<Response>;
|