wanderlog-mcp 1.0.0__tar.gz
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.
- wanderlog_mcp-1.0.0/.cursor/mcp.json +10 -0
- wanderlog_mcp-1.0.0/.cursor/rules/wanderlog.mdc +13 -0
- wanderlog_mcp-1.0.0/.gitignore +3 -0
- wanderlog_mcp-1.0.0/LICENSE +93 -0
- wanderlog_mcp-1.0.0/PKG-INFO +109 -0
- wanderlog_mcp-1.0.0/README.md +94 -0
- wanderlog_mcp-1.0.0/examples/prompts.md +7 -0
- wanderlog_mcp-1.0.0/mcp.json +10 -0
- wanderlog_mcp-1.0.0/pyproject.toml +29 -0
- wanderlog_mcp-1.0.0/skills/wanderlog/SKILL.md +25 -0
- wanderlog_mcp-1.0.0/wanderlog_agent.py +122 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Work in Wanderlog through Cotlet.dev
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Wanderlog through Cotlet.dev
|
|
8
|
+
|
|
9
|
+
- First call `cotlet_app_guide` with app "wanderlog".
|
|
10
|
+
- Then use `cotlet_browser_open`, `cotlet_browser_read` and `cotlet_browser_click`, one call at a time. Wait for each answer.
|
|
11
|
+
- At a sign-in page or CAPTCHA, stop and give the user the browser link.
|
|
12
|
+
- Ask the user before sending, publishing, deleting or paying.
|
|
13
|
+
- Close the browser with `cotlet_browser_close` when done.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Elastic License 2.0
|
|
2
|
+
|
|
3
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
12
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
13
|
+
available, and prepare derivative works of the software, in each case subject to
|
|
14
|
+
the limitations and conditions below.
|
|
15
|
+
|
|
16
|
+
## Limitations
|
|
17
|
+
|
|
18
|
+
You may not provide the software to third parties as a hosted or managed
|
|
19
|
+
service, where the service provides users with access to any substantial set of
|
|
20
|
+
the features or functionality of the software.
|
|
21
|
+
|
|
22
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
23
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
24
|
+
software that is protected by the license key.
|
|
25
|
+
|
|
26
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
27
|
+
of the licensor in the software. Any use of the licensor’s trademarks is subject
|
|
28
|
+
to applicable law.
|
|
29
|
+
|
|
30
|
+
## Patents
|
|
31
|
+
|
|
32
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
33
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
34
|
+
sale, import and have imported the software, in each case subject to the
|
|
35
|
+
limitations and conditions in this license. This license does not cover any
|
|
36
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
37
|
+
the software. If you or your company make any written claim that the software
|
|
38
|
+
infringes or contributes to infringement of any patent, your patent license for
|
|
39
|
+
the software granted under these terms ends immediately. If your company makes
|
|
40
|
+
such a claim, your patent license ends immediately for work on behalf of your
|
|
41
|
+
company.
|
|
42
|
+
|
|
43
|
+
## Notices
|
|
44
|
+
|
|
45
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
46
|
+
also gets a copy of these terms.
|
|
47
|
+
|
|
48
|
+
If you modify the software, you must include in any modified copies of the
|
|
49
|
+
software prominent notices stating that you have modified the software.
|
|
50
|
+
|
|
51
|
+
## No Other Rights
|
|
52
|
+
|
|
53
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
54
|
+
these terms.
|
|
55
|
+
|
|
56
|
+
## Termination
|
|
57
|
+
|
|
58
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
59
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
60
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
61
|
+
later than 30 days after you receive that notice, your licenses will be
|
|
62
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
63
|
+
reinstatement, any additional violation of these terms will cause your licenses
|
|
64
|
+
to terminate automatically and permanently.
|
|
65
|
+
|
|
66
|
+
## No Liability
|
|
67
|
+
|
|
68
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
69
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
70
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
71
|
+
legal claim.*
|
|
72
|
+
|
|
73
|
+
## Definitions
|
|
74
|
+
|
|
75
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
|
76
|
+
software the licensor makes available under these terms, including any portion
|
|
77
|
+
of it.
|
|
78
|
+
|
|
79
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
80
|
+
|
|
81
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
82
|
+
organization that you work for, plus all organizations that have control over,
|
|
83
|
+
are under the control of, or are under common control with that
|
|
84
|
+
organization. **control** means ownership of substantially all the assets of an
|
|
85
|
+
entity, or the power to direct its management and policies by vote, contract, or
|
|
86
|
+
otherwise. Control can be direct or indirect.
|
|
87
|
+
|
|
88
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
89
|
+
these terms.
|
|
90
|
+
|
|
91
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
92
|
+
|
|
93
|
+
**trademark** means trademarks, service marks, and similar rights.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: wanderlog-mcp
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Connect Wanderlog to Claude Code, ChatGPT and any AI agent through Cotlet.dev, a hosted MCP server. No Wanderlog API key needed.
|
|
5
|
+
Project-URL: Homepage, https://cotlet.dev/integrations/wanderlog-api-mcp-server?utm_source=pypi&utm_medium=package&utm_campaign=wanderlog
|
|
6
|
+
Project-URL: Source, https://github.com/cotlet-connect/wanderlog-mcp
|
|
7
|
+
Author-email: "Cotlet.dev" <contact@cotlet.dev>
|
|
8
|
+
License-Expression: Elastic-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: ai agent,chatgpt,claude,cotlet,mcp server,wanderlog,wanderlog api,wanderlog mcp
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Office/Business
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# How to connect Wanderlog to Claude Code, ChatGPT and any AI agent
|
|
17
|
+
|
|
18
|
+
**Yes, Claude, ChatGPT and other AI agents can work in your Wanderlog account.** Wanderlog has no public API and no official ChatGPT app. Cotlet.dev connects your own Wanderlog account to any AI agent, so the AI can build and edit your trips while you plan in plain words.
|
|
19
|
+
|
|
20
|
+
## What you can ask
|
|
21
|
+
|
|
22
|
+
> Make a 5-day Lisbon trip in Wanderlog with 3 places a day, close to each other.
|
|
23
|
+
|
|
24
|
+
> Add the restaurants from this list to day 2 of my Tokyo trip.
|
|
25
|
+
|
|
26
|
+
> Reorder my Rome itinerary so each day has the shortest walking route.
|
|
27
|
+
|
|
28
|
+
> What's still missing in my Iceland trip: hotels, transfers, opening hours?
|
|
29
|
+
|
|
30
|
+
> Copy my Paris trip and adapt it for a family with two kids.
|
|
31
|
+
|
|
32
|
+
## Connect in 2 minutes
|
|
33
|
+
|
|
34
|
+
Get your API key at https://cotlet.dev/app and export it as `COTLET_API_KEY`.
|
|
35
|
+
|
|
36
|
+
### Claude Code
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
claude mcp add --transport http cotlet https://cotlet.dev/mcp/v1 --header "Authorization: Bearer $COTLET_API_KEY"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### ChatGPT
|
|
43
|
+
|
|
44
|
+
Settings → Apps → add connector URL `https://cotlet.dev/mcp/v1`, then sign in with Cotlet.dev. No API key needed.
|
|
45
|
+
|
|
46
|
+
### Cursor
|
|
47
|
+
|
|
48
|
+
Copy `.cursor/mcp.json` from this repo into your project:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"mcpServers": {
|
|
53
|
+
"cotlet": {
|
|
54
|
+
"url": "https://cotlet.dev/mcp/v1",
|
|
55
|
+
"headers": {
|
|
56
|
+
"Authorization": "Bearer ${COTLET_API_KEY}"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Command line
|
|
64
|
+
|
|
65
|
+
Python 3.10+, nothing else to install. From PyPI:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install wanderlog-mcp # or run it once: uvx wanderlog-mcp connect
|
|
69
|
+
wanderlog-mcp connect
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Or straight from this repo:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
export COTLET_API_KEY="your-key"
|
|
76
|
+
python3 wanderlog_agent.py connect # ready config for Claude Code, Cursor, ChatGPT
|
|
77
|
+
python3 wanderlog_agent.py status # is Wanderlog ready in your Cotlet.dev account
|
|
78
|
+
python3 wanderlog_agent.py guide # Wanderlog screens and sign-in link
|
|
79
|
+
python3 wanderlog_agent.py read # open Wanderlog, read the page, close the browser
|
|
80
|
+
python3 wanderlog_agent.py tools # list Cotlet.dev tools
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Questions from Wanderlog users
|
|
84
|
+
|
|
85
|
+
**Does Wanderlog have an API?**
|
|
86
|
+
|
|
87
|
+
Wanderlog has no public, supported API. Cotlet.dev works in your own Wanderlog account through the Cloud Browser, so your AI agent can read and edit trips without one.
|
|
88
|
+
|
|
89
|
+
**How do I connect Wanderlog to ChatGPT?**
|
|
90
|
+
|
|
91
|
+
Add Cotlet.dev as an app in ChatGPT (Settings → Apps, connector URL `https://cotlet.dev/mcp/v1`), sign in to Wanderlog once in your Cotlet.dev Cloud Browser, and ask ChatGPT in plain words. No code and no Wanderlog API key.
|
|
92
|
+
|
|
93
|
+
**Is there a way to use Claude with Wanderlog?**
|
|
94
|
+
|
|
95
|
+
Yes. In Claude Code run the one-line `claude mcp add` command above; in the Claude app add `https://cotlet.dev/mcp/v1` as a custom connector. Claude then works in your own Wanderlog account.
|
|
96
|
+
|
|
97
|
+
**Is there a Wanderlog MCP server?**
|
|
98
|
+
|
|
99
|
+
Wanderlog has no official MCP server. Cotlet.dev is a hosted MCP server that works in Wanderlog for you, 24/7, with Claude, ChatGPT, Cursor, Codex, n8n, Make and Zapier.
|
|
100
|
+
|
|
101
|
+
## Also works with
|
|
102
|
+
|
|
103
|
+
- [All apps connected through Cotlet.dev](https://github.com/cotlet-connect)
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
More: https://cotlet.dev/integrations/wanderlog-api-mcp-server?utm_source=github&utm_medium=readme&utm_campaign=wanderlog
|
|
108
|
+
|
|
109
|
+
Start free: https://cotlet.dev/signup?app=wanderlog&utm_source=github&utm_medium=readme&utm_campaign=wanderlog
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# How to connect Wanderlog to Claude Code, ChatGPT and any AI agent
|
|
2
|
+
|
|
3
|
+
**Yes, Claude, ChatGPT and other AI agents can work in your Wanderlog account.** Wanderlog has no public API and no official ChatGPT app. Cotlet.dev connects your own Wanderlog account to any AI agent, so the AI can build and edit your trips while you plan in plain words.
|
|
4
|
+
|
|
5
|
+
## What you can ask
|
|
6
|
+
|
|
7
|
+
> Make a 5-day Lisbon trip in Wanderlog with 3 places a day, close to each other.
|
|
8
|
+
|
|
9
|
+
> Add the restaurants from this list to day 2 of my Tokyo trip.
|
|
10
|
+
|
|
11
|
+
> Reorder my Rome itinerary so each day has the shortest walking route.
|
|
12
|
+
|
|
13
|
+
> What's still missing in my Iceland trip: hotels, transfers, opening hours?
|
|
14
|
+
|
|
15
|
+
> Copy my Paris trip and adapt it for a family with two kids.
|
|
16
|
+
|
|
17
|
+
## Connect in 2 minutes
|
|
18
|
+
|
|
19
|
+
Get your API key at https://cotlet.dev/app and export it as `COTLET_API_KEY`.
|
|
20
|
+
|
|
21
|
+
### Claude Code
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
claude mcp add --transport http cotlet https://cotlet.dev/mcp/v1 --header "Authorization: Bearer $COTLET_API_KEY"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### ChatGPT
|
|
28
|
+
|
|
29
|
+
Settings → Apps → add connector URL `https://cotlet.dev/mcp/v1`, then sign in with Cotlet.dev. No API key needed.
|
|
30
|
+
|
|
31
|
+
### Cursor
|
|
32
|
+
|
|
33
|
+
Copy `.cursor/mcp.json` from this repo into your project:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"cotlet": {
|
|
39
|
+
"url": "https://cotlet.dev/mcp/v1",
|
|
40
|
+
"headers": {
|
|
41
|
+
"Authorization": "Bearer ${COTLET_API_KEY}"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Command line
|
|
49
|
+
|
|
50
|
+
Python 3.10+, nothing else to install. From PyPI:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install wanderlog-mcp # or run it once: uvx wanderlog-mcp connect
|
|
54
|
+
wanderlog-mcp connect
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or straight from this repo:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
export COTLET_API_KEY="your-key"
|
|
61
|
+
python3 wanderlog_agent.py connect # ready config for Claude Code, Cursor, ChatGPT
|
|
62
|
+
python3 wanderlog_agent.py status # is Wanderlog ready in your Cotlet.dev account
|
|
63
|
+
python3 wanderlog_agent.py guide # Wanderlog screens and sign-in link
|
|
64
|
+
python3 wanderlog_agent.py read # open Wanderlog, read the page, close the browser
|
|
65
|
+
python3 wanderlog_agent.py tools # list Cotlet.dev tools
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Questions from Wanderlog users
|
|
69
|
+
|
|
70
|
+
**Does Wanderlog have an API?**
|
|
71
|
+
|
|
72
|
+
Wanderlog has no public, supported API. Cotlet.dev works in your own Wanderlog account through the Cloud Browser, so your AI agent can read and edit trips without one.
|
|
73
|
+
|
|
74
|
+
**How do I connect Wanderlog to ChatGPT?**
|
|
75
|
+
|
|
76
|
+
Add Cotlet.dev as an app in ChatGPT (Settings → Apps, connector URL `https://cotlet.dev/mcp/v1`), sign in to Wanderlog once in your Cotlet.dev Cloud Browser, and ask ChatGPT in plain words. No code and no Wanderlog API key.
|
|
77
|
+
|
|
78
|
+
**Is there a way to use Claude with Wanderlog?**
|
|
79
|
+
|
|
80
|
+
Yes. In Claude Code run the one-line `claude mcp add` command above; in the Claude app add `https://cotlet.dev/mcp/v1` as a custom connector. Claude then works in your own Wanderlog account.
|
|
81
|
+
|
|
82
|
+
**Is there a Wanderlog MCP server?**
|
|
83
|
+
|
|
84
|
+
Wanderlog has no official MCP server. Cotlet.dev is a hosted MCP server that works in Wanderlog for you, 24/7, with Claude, ChatGPT, Cursor, Codex, n8n, Make and Zapier.
|
|
85
|
+
|
|
86
|
+
## Also works with
|
|
87
|
+
|
|
88
|
+
- [All apps connected through Cotlet.dev](https://github.com/cotlet-connect)
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
More: https://cotlet.dev/integrations/wanderlog-api-mcp-server?utm_source=github&utm_medium=readme&utm_campaign=wanderlog
|
|
93
|
+
|
|
94
|
+
Start free: https://cotlet.dev/signup?app=wanderlog&utm_source=github&utm_medium=readme&utm_campaign=wanderlog
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Example prompts for Wanderlog
|
|
2
|
+
|
|
3
|
+
- Make a 5-day Lisbon trip in Wanderlog with 3 places a day, close to each other.
|
|
4
|
+
- Add the restaurants from this list to day 2 of my Tokyo trip.
|
|
5
|
+
- Reorder my Rome itinerary so each day has the shortest walking route.
|
|
6
|
+
- What's still missing in my Iceland trip: hotels, transfers, opening hours?
|
|
7
|
+
- Copy my Paris trip and adapt it for a family with two kids.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "wanderlog-mcp"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "Connect Wanderlog to Claude Code, ChatGPT and any AI agent through Cotlet.dev, a hosted MCP server. No Wanderlog API key needed."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "Elastic-2.0"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.10"
|
|
9
|
+
authors = [{ name = "Cotlet.dev", email = "contact@cotlet.dev" }]
|
|
10
|
+
keywords = ["wanderlog", "wanderlog api", "wanderlog mcp", "mcp server", "claude", "chatgpt", "ai agent", "cotlet"]
|
|
11
|
+
classifiers = ["Programming Language :: Python :: 3", "Topic :: Office/Business"]
|
|
12
|
+
dependencies = []
|
|
13
|
+
|
|
14
|
+
[project.urls]
|
|
15
|
+
Homepage = "https://cotlet.dev/integrations/wanderlog-api-mcp-server?utm_source=pypi&utm_medium=package&utm_campaign=wanderlog"
|
|
16
|
+
Source = "https://github.com/cotlet-connect/wanderlog-mcp"
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
wanderlog-mcp = "wanderlog_agent:main"
|
|
20
|
+
|
|
21
|
+
[build-system]
|
|
22
|
+
requires = ["hatchling>=1.27"]
|
|
23
|
+
build-backend = "hatchling.build"
|
|
24
|
+
|
|
25
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
26
|
+
"wanderlog_agent.py" = "wanderlog_agent.py"
|
|
27
|
+
|
|
28
|
+
[tool.hatch.build.targets.sdist]
|
|
29
|
+
include = ["wanderlog_agent.py", "README.md", "LICENSE", "mcp.json", "skills", "examples", ".cursor"]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wanderlog-cotlet
|
|
3
|
+
description: Connect Wanderlog to Claude Code, ChatGPT and any AI agent through Cotlet.dev, so the agent can trip planning and itineraries in your own signed-in Wanderlog account.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Wanderlog through Cotlet.dev
|
|
7
|
+
|
|
8
|
+
## What it does
|
|
9
|
+
|
|
10
|
+
Cotlet.dev runs your own Chrome in the cloud. The agent works in Wanderlog (wanderlog.com) there, signed in as you.
|
|
11
|
+
|
|
12
|
+
## Setup
|
|
13
|
+
|
|
14
|
+
1. Get an API key at https://cotlet.dev/app.
|
|
15
|
+
2. Add the MCP server `https://cotlet.dev/mcp/v1` with header `Authorization: Bearer <your key>`.
|
|
16
|
+
|
|
17
|
+
## Working rules
|
|
18
|
+
|
|
19
|
+
- First call `cotlet_app_guide` with app "wanderlog".
|
|
20
|
+
- Then use `cotlet_browser_open`, `cotlet_browser_read` and `cotlet_browser_click`, one call at a time. Wait for each answer.
|
|
21
|
+
- At a sign-in page or CAPTCHA, stop and give the user the browser link.
|
|
22
|
+
- Ask the user before sending, publishing, deleting or paying.
|
|
23
|
+
- Close the browser with `cotlet_browser_close` when done.
|
|
24
|
+
|
|
25
|
+
More: https://cotlet.dev/integrations/wanderlog-api-mcp-server?utm_source=clawhub&utm_medium=skill&utm_campaign=wanderlog
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Wanderlog through Cotlet.dev: small CLI over the Cotlet.dev MCP server (stdlib only)."""
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
import urllib.error
|
|
8
|
+
import urllib.request
|
|
9
|
+
|
|
10
|
+
START_URL = "https://wanderlog.com"
|
|
11
|
+
SLUG = "wanderlog"
|
|
12
|
+
URL = "https://cotlet.dev/mcp/v1"
|
|
13
|
+
GUIDE_FIELD = "app"
|
|
14
|
+
KEY_HELP = "Set COTLET_API_KEY. Get a key at https://cotlet.dev/app"
|
|
15
|
+
|
|
16
|
+
CONFIG = {"mcpServers": {"cotlet": {"url": URL, "headers": {"Authorization": "Bearer ${COTLET_API_KEY}"}}}}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Client:
|
|
20
|
+
def __init__(self, key):
|
|
21
|
+
self.key = key
|
|
22
|
+
self.session = None
|
|
23
|
+
self.next_id = 0
|
|
24
|
+
|
|
25
|
+
def _post(self, payload):
|
|
26
|
+
headers = {
|
|
27
|
+
"Authorization": "Bearer " + self.key,
|
|
28
|
+
"Accept": "application/json, text/event-stream",
|
|
29
|
+
"Content-Type": "application/json",
|
|
30
|
+
}
|
|
31
|
+
if self.session:
|
|
32
|
+
headers["Mcp-Session-Id"] = self.session
|
|
33
|
+
req = urllib.request.Request(URL, json.dumps(payload).encode(), headers, method="POST")
|
|
34
|
+
try:
|
|
35
|
+
with urllib.request.urlopen(req, timeout=120) as resp:
|
|
36
|
+
self.session = resp.headers.get("Mcp-Session-Id") or self.session
|
|
37
|
+
return resp.read().decode(), resp.headers.get("Content-Type", "")
|
|
38
|
+
except urllib.error.HTTPError as e:
|
|
39
|
+
raise RuntimeError("HTTP %s: %s" % (e.code, e.read().decode(errors="replace")[:300]))
|
|
40
|
+
|
|
41
|
+
@staticmethod
|
|
42
|
+
def _parse(body, ctype, rid):
|
|
43
|
+
if "text/event-stream" in ctype:
|
|
44
|
+
for line in body.splitlines():
|
|
45
|
+
if line.startswith("data:"):
|
|
46
|
+
try:
|
|
47
|
+
msg = json.loads(line[5:].strip())
|
|
48
|
+
except ValueError:
|
|
49
|
+
continue
|
|
50
|
+
if msg.get("id") == rid:
|
|
51
|
+
return msg
|
|
52
|
+
raise RuntimeError("No JSON-RPC answer in stream")
|
|
53
|
+
return json.loads(body)
|
|
54
|
+
|
|
55
|
+
def rpc(self, method, params=None):
|
|
56
|
+
self.next_id += 1
|
|
57
|
+
rid = self.next_id
|
|
58
|
+
body, ctype = self._post({"jsonrpc": "2.0", "id": rid, "method": method, "params": params or {}})
|
|
59
|
+
msg = self._parse(body, ctype, rid)
|
|
60
|
+
if "error" in msg:
|
|
61
|
+
raise RuntimeError(msg["error"].get("message", str(msg["error"])))
|
|
62
|
+
return msg.get("result", {})
|
|
63
|
+
|
|
64
|
+
def start(self):
|
|
65
|
+
self.rpc("initialize", {
|
|
66
|
+
"protocolVersion": "2025-06-18",
|
|
67
|
+
"capabilities": {},
|
|
68
|
+
"clientInfo": {"name": SLUG + "-mcp", "version": "1.0.0"},
|
|
69
|
+
})
|
|
70
|
+
self._post({"jsonrpc": "2.0", "method": "notifications/initialized"})
|
|
71
|
+
|
|
72
|
+
def call(self, tool, args):
|
|
73
|
+
res = self.rpc("tools/call", {"name": tool, "arguments": args})
|
|
74
|
+
text = "\n".join(c.get("text", "") for c in res.get("content", []) if c.get("type") == "text")
|
|
75
|
+
if res.get("isError"):
|
|
76
|
+
raise RuntimeError(text or "tool error")
|
|
77
|
+
return text
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def connect():
|
|
81
|
+
print("Claude Code:\n claude mcp add --transport http cotlet %s --header \"Authorization: Bearer $COTLET_API_KEY\"\n" % URL)
|
|
82
|
+
print("Cursor (.cursor/mcp.json):\n" + json.dumps(CONFIG, indent=2) + "\n")
|
|
83
|
+
print("ChatGPT:\n Settings -> Apps -> add connector URL %s, sign in with Cotlet.dev (no API key)." % URL)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def main():
|
|
87
|
+
p = argparse.ArgumentParser(description="Wanderlog through Cotlet.dev")
|
|
88
|
+
sub = p.add_subparsers(dest="cmd", required=True)
|
|
89
|
+
for name in ("connect", "status", "guide", "tools"):
|
|
90
|
+
sub.add_parser(name)
|
|
91
|
+
r = sub.add_parser("read")
|
|
92
|
+
r.add_argument("url", nargs="?")
|
|
93
|
+
args = p.parse_args()
|
|
94
|
+
if args.cmd == "connect":
|
|
95
|
+
return connect()
|
|
96
|
+
key = os.environ.get("COTLET_API_KEY")
|
|
97
|
+
if not key:
|
|
98
|
+
print(KEY_HELP)
|
|
99
|
+
sys.exit(2)
|
|
100
|
+
try:
|
|
101
|
+
c = Client(key)
|
|
102
|
+
c.start()
|
|
103
|
+
if args.cmd == "tools":
|
|
104
|
+
print("\n".join(t["name"] for t in c.rpc("tools/list").get("tools", [])))
|
|
105
|
+
elif args.cmd == "status":
|
|
106
|
+
print(c.call("cotlet_apps", {"app": SLUG}))
|
|
107
|
+
elif args.cmd == "guide":
|
|
108
|
+
print(c.call("cotlet_app_guide", {GUIDE_FIELD: SLUG}))
|
|
109
|
+
elif args.cmd == "read":
|
|
110
|
+
# Works in the user's Web browser, where they sign in to the app once.
|
|
111
|
+
c.call("cotlet_browser_open", {"url": args.url or START_URL})
|
|
112
|
+
try:
|
|
113
|
+
print(c.call("cotlet_browser_read", {}))
|
|
114
|
+
finally:
|
|
115
|
+
c.call("cotlet_browser_close", {})
|
|
116
|
+
except Exception as e:
|
|
117
|
+
print("Error: %s" % e, file=sys.stderr)
|
|
118
|
+
sys.exit(1)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
if __name__ == "__main__":
|
|
122
|
+
main()
|