agentgate-mcp 0.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.
@@ -0,0 +1,56 @@
1
+ # AgentGate Architecture
2
+
3
+ ## How it works
4
+
5
+ 1. User runs `agentgate login` → opens Chromium → signs into Google → browser profile saved
6
+ 2. `agentgate serve` starts MCP server over stdio
7
+ 3. AI agent calls `get_or_create_key({ service, signup_url, api_key_url })`
8
+ 4. Orchestrator checks SQLite cache for an active key
9
+ 5. If cached: returns immediately
10
+ 6. If not cached: launches browser with saved Google profile
11
+ 7. Smart navigation: finds Google sign-in → authenticates → navigates to API keys → extracts key
12
+ 8. Key is stored in SQLite and returned to agent
13
+
14
+ ## Core modules
15
+
16
+ - `src/cli.js` — CLI entry point (`login`, `serve`, `doctor`, `scaffold`)
17
+ - `src/mcp-server.js` — MCP JSON-RPC over stdio
18
+ - `src/orchestrator.js` — Key lifecycle: cache check → create → store
19
+ - `src/playwright-engine.js` — Browser automation with persistent Google session
20
+ - `src/signup-engine.js` — Logging wrapper around PlaywrightEngine
21
+ - `src/browser-runtime.js` — Workflow DSL executor (for service recipes)
22
+ - `src/vault.js` — AES-256-GCM encrypted local vault
23
+ - `src/db.js` — SQLite key + alias storage
24
+ - `src/registry.js` — Optional service recipe loader
25
+ - `src/scaffold.js` — Recipe template generator
26
+ - `src/logger.js` — Structured JSON logging with rotation
27
+
28
+ ## Two modes of key creation
29
+
30
+ ### Smart mode (default)
31
+ No recipe needed. Engine uses heuristics to:
32
+ 1. Find and click Google sign-in buttons
33
+ 2. Handle OAuth popup
34
+ 3. Navigate to API keys page
35
+ 4. Click "Create API Key" buttons
36
+ 5. Extract the key from the page
37
+
38
+ ### Recipe mode (optional)
39
+ For services with non-standard flows, a JSON recipe in `services/` provides
40
+ an explicit workflow with DSL actions (goto, click, fill, extract, etc.).
41
+
42
+ ## Security
43
+
44
+ - Browser profile stored locally in `~/.agentgate/browser-profile/`
45
+ - Vault encrypted with AES-256-GCM (keyring + vault file)
46
+ - SQLite database stored locally
47
+ - API keys masked in logs (last 4 chars visible)
48
+ - File permissions 0o600 on sensitive files
49
+ - No cloud sync, no telemetry
50
+
51
+ ## MCP protocol
52
+
53
+ - Version: 2024-11-05
54
+ - Methods: `initialize`, `ping`, `tools/list`, `tools/call`
55
+ - Notifications: `notifications/initialized`, `notifications/cancelled`
56
+ - Tools: `get_or_create_key`, `list_my_keys`, `revoke_key`, `check_key_status`
package/MCP_TOOLS.md ADDED
@@ -0,0 +1,45 @@
1
+ # AgentGate MCP Tools
2
+
3
+ ## `get_or_create_key`
4
+
5
+ Works for **any** service. No pre-configuration needed.
6
+
7
+ Input:
8
+
9
+ ```json
10
+ {
11
+ "service": "twelvelabs",
12
+ "signup_url": "https://api.twelvelabs.io/signup",
13
+ "api_key_url": "https://api.twelvelabs.io/dashboard/api-keys"
14
+ }
15
+ ```
16
+
17
+ Parameters:
18
+ - `service` (required) — Service name, used as cache key
19
+ - `signup_url` (required) — Where to start the sign-up/login flow
20
+ - `api_key_url` (optional) — Direct link to the API keys dashboard
21
+
22
+ Behavior:
23
+ 1. Returns cached key from SQLite if one exists
24
+ 2. Otherwise opens browser with saved Google session
25
+ 3. Navigates to signup_url, finds Google sign-in, authenticates
26
+ 4. Navigates to api_key_url (if provided), creates and extracts key
27
+ 5. Caches key in SQLite and returns it
28
+
29
+ ## `list_my_keys`
30
+
31
+ Input: `{}`
32
+
33
+ Returns all API keys in the local database (active and revoked).
34
+
35
+ ## `revoke_key`
36
+
37
+ Input: `{ "service": "openai" }`
38
+
39
+ Marks the local key as revoked. Does NOT revoke it on the provider side.
40
+
41
+ ## `check_key_status`
42
+
43
+ Input: `{ "service": "openai" }`
44
+
45
+ Returns whether an active key exists. Does not create one.
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # AgentGate
2
+
3
+ MCP server that lets AI agents get API keys for **any** service. Sign in with Google once, then your agent can create keys anywhere.
4
+
5
+ ## How it works
6
+
7
+ 1. You sign into Google in a real browser (one time)
8
+ 2. AgentGate saves that browser session
9
+ 3. When your AI agent needs an API key, AgentGate opens a browser with your Google session, signs up for the service, and extracts the key
10
+ 4. Keys are cached locally — second request is instant
11
+
12
+ No hardcoded services. No config files per provider. Works for anything with "Sign in with Google".
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install -g agentgate-mcp
18
+ ```
19
+
20
+ Requires Node.js 23+ (for built-in SQLite support).
21
+
22
+ ## Setup (one time)
23
+
24
+ ```bash
25
+ agentgate login
26
+ ```
27
+
28
+ This opens Chromium — sign into your Google account, then close the browser. Done.
29
+
30
+ ## Add to Claude Code
31
+
32
+ ```bash
33
+ claude mcp add agentgate -- agentgate serve
34
+ ```
35
+
36
+ Or manually add to your MCP config:
37
+
38
+ ```json
39
+ {
40
+ "mcpServers": {
41
+ "agentgate": {
42
+ "command": "agentgate",
43
+ "args": ["serve"]
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ Just ask your AI agent naturally:
52
+
53
+ - *"Get me an API key for Twelve Labs"*
54
+ - *"I need an OpenAI key"*
55
+ - *"Set me up with a Replicate key"*
56
+ - *"Show all my keys"*
57
+ - *"Revoke my openai key"*
58
+
59
+ ## MCP Tools
60
+
61
+ ### `get_or_create_key`
62
+
63
+ Works for **any** service. Just provide the name and URLs.
64
+
65
+ ```json
66
+ {
67
+ "service": "twelvelabs",
68
+ "signup_url": "https://api.twelvelabs.io/signup",
69
+ "api_key_url": "https://api.twelvelabs.io/dashboard/api-keys"
70
+ }
71
+ ```
72
+
73
+ | Parameter | Required | Description |
74
+ |-----------|----------|-------------|
75
+ | `service` | Yes | Service name (used as cache key) |
76
+ | `signup_url` | Yes | Signup or login page URL |
77
+ | `api_key_url` | No | Direct link to API keys dashboard |
78
+
79
+ ### `list_my_keys`
80
+
81
+ Returns all stored keys (active and revoked).
82
+
83
+ ### `revoke_key`
84
+
85
+ Removes a key from local store. `{ "service": "openai" }`
86
+
87
+ ### `check_key_status`
88
+
89
+ Checks if an active key exists. `{ "service": "openai" }`
90
+
91
+ ## Service Recipes (optional)
92
+
93
+ For services with non-standard flows, add a JSON recipe:
94
+
95
+ ```bash
96
+ agentgate scaffold myservice https://myservice.com/signup
97
+ ```
98
+
99
+ Most services work without a recipe.
100
+
101
+ ## Commands
102
+
103
+ | Command | Description |
104
+ |---------|-------------|
105
+ | `agentgate login` | Sign in with Google (opens browser) |
106
+ | `agentgate serve` | Start MCP server |
107
+ | `agentgate doctor` | Health check |
108
+ | `agentgate scaffold <name> <url>` | Generate a service recipe |
109
+
110
+ ## How it stays secure
111
+
112
+ - Your Google session stays on **your machine** in `~/.agentgate/browser-profile/`
113
+ - API keys stored in local SQLite, encrypted vault uses AES-256-GCM
114
+ - Nothing is sent to any cloud — fully local
115
+ - No telemetry
116
+
117
+ ## Troubleshooting
118
+
119
+ ```bash
120
+ # Check everything is working
121
+ agentgate doctor
122
+
123
+ # Check logs
124
+ cat ~/.agentgate/logs/agentgate.log
125
+
126
+ # Re-login if session expired
127
+ agentgate login
128
+ ```
129
+
130
+ ## Development
131
+
132
+ ```bash
133
+ git clone https://github.com/junaid-mahmood/Agent-Gate.git
134
+ cd Agent-Gate
135
+ npm install
136
+ npx playwright install chromium
137
+ npm test
138
+ ```
139
+
140
+ ## License
141
+
142
+ MIT
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "agentgate-mcp",
3
+ "version": "0.2.0",
4
+ "description": "MCP server that lets AI agents get API keys for any service via Google sign-in",
5
+ "type": "module",
6
+ "bin": {
7
+ "agentgate": "./src/cli.js"
8
+ },
9
+ "files": [
10
+ "src/",
11
+ "services/",
12
+ "README.md",
13
+ "ARCHITECTURE.md",
14
+ "MCP_TOOLS.md"
15
+ ],
16
+ "scripts": {
17
+ "start": "node --disable-warning=ExperimentalWarning src/cli.js serve",
18
+ "login": "node --disable-warning=ExperimentalWarning src/cli.js login",
19
+ "doctor": "node --disable-warning=ExperimentalWarning src/cli.js doctor",
20
+ "scaffold": "node --disable-warning=ExperimentalWarning src/cli.js scaffold",
21
+ "test": "node --disable-warning=ExperimentalWarning --test test/run.js",
22
+ "postinstall": "npx playwright install chromium 2>/dev/null || echo 'Run: npx playwright install chromium'"
23
+ },
24
+ "dependencies": {
25
+ "playwright": "^1.55.0"
26
+ },
27
+ "engines": {
28
+ "node": ">=23.0.0"
29
+ },
30
+ "keywords": [
31
+ "mcp",
32
+ "mcp-server",
33
+ "api-keys",
34
+ "ai-agents",
35
+ "claude",
36
+ "playwright",
37
+ "automation",
38
+ "google-sign-in",
39
+ "developer-tools"
40
+ ],
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/junaid-mahmood/Agent-Gate"
44
+ },
45
+ "homepage": "https://github.com/junaid-mahmood/Agent-Gate#readme",
46
+ "bugs": {
47
+ "url": "https://github.com/junaid-mahmood/Agent-Gate/issues"
48
+ },
49
+ "author": "Junaid Mahmood",
50
+ "license": "MIT"
51
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "replace_me",
3
+ "signup_url": "https://example.com/signup",
4
+ "requires": {
5
+ "google": false,
6
+ "card": false
7
+ },
8
+ "runtime": {
9
+ "headless": true
10
+ },
11
+ "workflow": [
12
+ { "type": "goto", "url": "{{service.signup_url}}" },
13
+ { "type": "wait_for", "selector": "body" },
14
+
15
+ { "type": "fill", "selector": "input[name='email']", "value": "{{generated.emailAlias}}" },
16
+ { "type": "fill", "selector": "input[name='password']", "value": "{{generated.password}}" },
17
+ { "type": "click", "selector": "button[type='submit']" },
18
+ { "type": "store_alias", "emailPath": "generated.emailAlias", "passwordPath": "generated.password" },
19
+
20
+ { "type": "wait_for_email_code", "target": "scratch.emailCode", "timeoutMs": 120000 },
21
+ { "type": "fill", "selector": "input[name='verification_code']", "value": "{{scratch.emailCode}}" },
22
+ { "type": "click", "selector": "button[type='submit']" },
23
+
24
+ { "type": "solve_captcha", "target": "scratch.captchaToken", "provider": "capsolver" },
25
+ { "type": "fill_card" },
26
+
27
+ { "type": "goto", "url": "https://example.com/dashboard/api-keys" },
28
+ { "type": "click", "selector": "text=Create API Key" },
29
+
30
+ { "type": "extract_text", "selector": "body", "target": "scratch.pageText" },
31
+ { "type": "regex_extract", "source": "scratch.pageText", "pattern": "api[_-]?key[:\\s]+([A-Za-z0-9_\\-]{20,})", "target": "result.apiKey" },
32
+ { "type": "assert_present", "path": "result.apiKey", "message": "API key not found in page output" }
33
+ ]
34
+ }