notte-mcp 1.4.4__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.
- notte_mcp-1.4.4/.gitignore +181 -0
- notte_mcp-1.4.4/PKG-INFO +89 -0
- notte_mcp-1.4.4/README.md +78 -0
- notte_mcp-1.4.4/pyproject.toml +24 -0
- notte_mcp-1.4.4/src/notte_mcp/__init__.py +3 -0
- notte_mcp-1.4.4/src/notte_mcp/server.py +157 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
ignore.*
|
|
171
|
+
llm_usage.jsonl
|
|
172
|
+
llm_parsing_error.jsonl
|
|
173
|
+
traces/
|
|
174
|
+
|
|
175
|
+
**/__pycache__/**
|
|
176
|
+
.DS_Store
|
|
177
|
+
**/.DS_Store
|
|
178
|
+
old
|
|
179
|
+
notebook
|
|
180
|
+
examples/benchmark_params.toml
|
|
181
|
+
**/*/trending.csv
|
notte_mcp-1.4.4/PKG-INFO
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: notte-mcp
|
|
3
|
+
Version: 1.4.4
|
|
4
|
+
Summary: The MCP server for Notte
|
|
5
|
+
Author-email: Notte Team <hello@notte.cc>
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Requires-Dist: mcp[cli]>=1.6.0
|
|
8
|
+
Requires-Dist: notte-sdk==v1.4.4
|
|
9
|
+
Requires-Dist: python-dotenv>=1.0.1
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
<div align="center">
|
|
13
|
+
<p>
|
|
14
|
+
⚡️ we outperform other web agents in speed, costs and reliability 👉🏼 <a href="https://github.com/nottelabs/open-operator-evals">read more on open-operator-evals</a>
|
|
15
|
+
</p>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<p align="center">
|
|
19
|
+
<img src="../../docs/logo/bgd.png" alt="Notte Logo" width="100%">
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
# Notte MCP Server
|
|
23
|
+
|
|
24
|
+
<div align="center">
|
|
25
|
+
<h1>Notte MCP Server</h1>
|
|
26
|
+
<p><em>MCP server for all Notte tools in the agentic ecosystem.</em></p>
|
|
27
|
+
<p><strong>Manage your sessions. Run agents. Take control: observe, scrape, act, authenticate.</strong></p>
|
|
28
|
+
<hr/>
|
|
29
|
+
</div>
|
|
30
|
+
[The Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) provides a standardized protocol for connecting LLM applications with external tools and data sources. It enables seamless integration between language models and the context they need, whether you're developing an AI-powered IDE, building a chat interface, or designing custom AI workflows.
|
|
31
|
+
|
|
32
|
+
## Available Tools
|
|
33
|
+
|
|
34
|
+
### Session Management
|
|
35
|
+
|
|
36
|
+
| Tool | Description |
|
|
37
|
+
|------|-------------|
|
|
38
|
+
| `notte_start_session` | Start a new cloud browser session |
|
|
39
|
+
| `notte_list_sessions` | List all active browser sessions |
|
|
40
|
+
| `notte_stop_session` | Stop the current session |
|
|
41
|
+
|
|
42
|
+
### Page Interaction & Scraping
|
|
43
|
+
|
|
44
|
+
| Tool | Description |
|
|
45
|
+
|------|-------------|
|
|
46
|
+
| `notte_observe` | Observe elements and available actions on the current page |
|
|
47
|
+
| `notte_screenshot` | Take a screenshot of the current page |
|
|
48
|
+
| `notte_scrape` | Extract structured data from the current page |
|
|
49
|
+
| `notte_step` | Execute an action on the current page |
|
|
50
|
+
|
|
51
|
+
### Agent Operations
|
|
52
|
+
|
|
53
|
+
| Tool | Description |
|
|
54
|
+
|------|-------------|
|
|
55
|
+
| `notte_operator` | Run a Notte agent to complete a task on any website |
|
|
56
|
+
|
|
57
|
+
## Getting Started
|
|
58
|
+
|
|
59
|
+
1. Install the required dependencies:
|
|
60
|
+
```bash
|
|
61
|
+
pip install notte-mcp
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
2. Set up your environment variables:
|
|
65
|
+
```bash
|
|
66
|
+
export NOTTE_API_KEY="your-api-key"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
3. Start the MCP server:
|
|
70
|
+
```bash
|
|
71
|
+
python -m notte_mcp.server
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
> note: you can also start the server locally using `uv run mcp dev packages/notte-mcp/src/notte_mcp/server.py --with-editable .`
|
|
75
|
+
|
|
76
|
+
To use the MCP in cursor or claude computer use, you can use the following json:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"notte-mcp": {
|
|
82
|
+
"url": "http://localhost:8000/sse",
|
|
83
|
+
"env": {
|
|
84
|
+
"NOTTE_API_KEY": "<your-notte-api-key>"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<p>
|
|
3
|
+
⚡️ we outperform other web agents in speed, costs and reliability 👉🏼 <a href="https://github.com/nottelabs/open-operator-evals">read more on open-operator-evals</a>
|
|
4
|
+
</p>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="../../docs/logo/bgd.png" alt="Notte Logo" width="100%">
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
# Notte MCP Server
|
|
12
|
+
|
|
13
|
+
<div align="center">
|
|
14
|
+
<h1>Notte MCP Server</h1>
|
|
15
|
+
<p><em>MCP server for all Notte tools in the agentic ecosystem.</em></p>
|
|
16
|
+
<p><strong>Manage your sessions. Run agents. Take control: observe, scrape, act, authenticate.</strong></p>
|
|
17
|
+
<hr/>
|
|
18
|
+
</div>
|
|
19
|
+
[The Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) provides a standardized protocol for connecting LLM applications with external tools and data sources. It enables seamless integration between language models and the context they need, whether you're developing an AI-powered IDE, building a chat interface, or designing custom AI workflows.
|
|
20
|
+
|
|
21
|
+
## Available Tools
|
|
22
|
+
|
|
23
|
+
### Session Management
|
|
24
|
+
|
|
25
|
+
| Tool | Description |
|
|
26
|
+
|------|-------------|
|
|
27
|
+
| `notte_start_session` | Start a new cloud browser session |
|
|
28
|
+
| `notte_list_sessions` | List all active browser sessions |
|
|
29
|
+
| `notte_stop_session` | Stop the current session |
|
|
30
|
+
|
|
31
|
+
### Page Interaction & Scraping
|
|
32
|
+
|
|
33
|
+
| Tool | Description |
|
|
34
|
+
|------|-------------|
|
|
35
|
+
| `notte_observe` | Observe elements and available actions on the current page |
|
|
36
|
+
| `notte_screenshot` | Take a screenshot of the current page |
|
|
37
|
+
| `notte_scrape` | Extract structured data from the current page |
|
|
38
|
+
| `notte_step` | Execute an action on the current page |
|
|
39
|
+
|
|
40
|
+
### Agent Operations
|
|
41
|
+
|
|
42
|
+
| Tool | Description |
|
|
43
|
+
|------|-------------|
|
|
44
|
+
| `notte_operator` | Run a Notte agent to complete a task on any website |
|
|
45
|
+
|
|
46
|
+
## Getting Started
|
|
47
|
+
|
|
48
|
+
1. Install the required dependencies:
|
|
49
|
+
```bash
|
|
50
|
+
pip install notte-mcp
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
2. Set up your environment variables:
|
|
54
|
+
```bash
|
|
55
|
+
export NOTTE_API_KEY="your-api-key"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
3. Start the MCP server:
|
|
59
|
+
```bash
|
|
60
|
+
python -m notte_mcp.server
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> note: you can also start the server locally using `uv run mcp dev packages/notte-mcp/src/notte_mcp/server.py --with-editable .`
|
|
64
|
+
|
|
65
|
+
To use the MCP in cursor or claude computer use, you can use the following json:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"mcpServers": {
|
|
70
|
+
"notte-mcp": {
|
|
71
|
+
"url": "http://localhost:8000/sse",
|
|
72
|
+
"env": {
|
|
73
|
+
"NOTTE_API_KEY": "<your-notte-api-key>"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "notte-mcp"
|
|
3
|
+
version = "v1.4.4"
|
|
4
|
+
description = "The MCP server for Notte"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Notte Team ", email = "hello@notte.cc" }
|
|
8
|
+
]
|
|
9
|
+
packages = [
|
|
10
|
+
{ include = "notte_mcp", from = "src" },
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
requires-python = ">=3.11"
|
|
15
|
+
dependencies = [
|
|
16
|
+
"python-dotenv>=1.0.1",
|
|
17
|
+
"mcp[cli]>=1.6.0",
|
|
18
|
+
"notte-sdk==v1.4.4",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["hatchling"]
|
|
24
|
+
build-backend = "hatchling.build"
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import pathlib
|
|
3
|
+
from collections.abc import Sequence
|
|
4
|
+
from typing import Annotated
|
|
5
|
+
|
|
6
|
+
from dotenv import load_dotenv
|
|
7
|
+
from mcp.server.fastmcp import FastMCP, Image
|
|
8
|
+
from notte_sdk import NotteClient, __version__
|
|
9
|
+
from notte_sdk.types import ObserveResponse, ScrapeResponse, SessionResponse
|
|
10
|
+
|
|
11
|
+
_ = load_dotenv()
|
|
12
|
+
|
|
13
|
+
mcp_server_path = pathlib.Path(__file__).absolute()
|
|
14
|
+
session: SessionResponse | None = None
|
|
15
|
+
|
|
16
|
+
os.environ["NOTTE_MCP_SERVER_PATH"] = str(mcp_server_path)
|
|
17
|
+
|
|
18
|
+
MAX_AGENT_WAIT_TIME = 120
|
|
19
|
+
|
|
20
|
+
notte = NotteClient(api_key=os.getenv("NOTTE_API_KEY"))
|
|
21
|
+
|
|
22
|
+
# Create an MCP server
|
|
23
|
+
mcp = FastMCP(
|
|
24
|
+
name="Notte MCP Server for Notte Browser Sessions and Web Agents Operators",
|
|
25
|
+
request_timeout=MAX_AGENT_WAIT_TIME,
|
|
26
|
+
# TOOD: coment out this line for local testing
|
|
27
|
+
dependencies=[f"notte-sdk=={__version__}", "mcp[cli]>=1.6.0"],
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def get_session_id() -> str:
|
|
32
|
+
global session
|
|
33
|
+
if session is None:
|
|
34
|
+
response = notte.sessions.start()
|
|
35
|
+
session = response
|
|
36
|
+
return session.session_id
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@mcp.tool(description="Start a new cloud browser session using Notte")
|
|
40
|
+
def notte_start_session() -> str:
|
|
41
|
+
"""Start a new Notte session"""
|
|
42
|
+
response = notte.sessions.start()
|
|
43
|
+
global session
|
|
44
|
+
session = response
|
|
45
|
+
return f"Session {session.session_id} started"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@mcp.tool(description="List all Notte Cloud Browser active sessions")
|
|
49
|
+
def notte_list_sessions() -> Sequence[SessionResponse]:
|
|
50
|
+
"""List all active Notte sessions"""
|
|
51
|
+
return notte.sessions.list(only_active=True)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@mcp.tool(description="Stop the current Notte session")
|
|
55
|
+
def notte_stop_session() -> str:
|
|
56
|
+
"""Stop the current Notte session"""
|
|
57
|
+
session_id = get_session_id()
|
|
58
|
+
_ = notte.sessions.stop(session_id=session_id)
|
|
59
|
+
global session
|
|
60
|
+
session = None
|
|
61
|
+
return f"Session {session_id} stopped"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@mcp.tool(
|
|
65
|
+
description="Takes a screenshot of the current page. Use this tool to learn where you are on the page when navigating. Only use this tool when the other tools are not sufficient to get the information you need."
|
|
66
|
+
)
|
|
67
|
+
def notte_screenshot() -> Image:
|
|
68
|
+
"""Takes a screenshot of the current page"""
|
|
69
|
+
session_id = get_session_id()
|
|
70
|
+
response = notte.sessions.page.observe(session_id=session_id)
|
|
71
|
+
assert response.screenshot is not None
|
|
72
|
+
return Image(
|
|
73
|
+
data=response.screenshot,
|
|
74
|
+
format="png",
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@mcp.tool(
|
|
79
|
+
description="Observes elements on the web page. Use this tool to observe elements that you can later use in an action. Use observe instead of extract when dealing with actionable (interactable) elements rather than text."
|
|
80
|
+
)
|
|
81
|
+
def notte_observe(
|
|
82
|
+
url: Annotated[
|
|
83
|
+
str | None,
|
|
84
|
+
"The URL of the webpage to observe. If not provided, the current page in the Notte Browser Session will be observed.",
|
|
85
|
+
] = None,
|
|
86
|
+
) -> ObserveResponse:
|
|
87
|
+
"""Observe the current page and the available actions on it"""
|
|
88
|
+
session_id = get_session_id()
|
|
89
|
+
response = notte.sessions.page.observe(session_id=session_id, url=url)
|
|
90
|
+
response.screenshot = None
|
|
91
|
+
assert session is not None
|
|
92
|
+
return ObserveResponse.from_obs(response, session=session)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@mcp.tool(description="Scrape the current page data")
|
|
96
|
+
def notte_scrape(
|
|
97
|
+
url: Annotated[
|
|
98
|
+
str | None,
|
|
99
|
+
"The URL of the webpage scrape. If not provided, the current page in the Notte Browser Session will be scraped.",
|
|
100
|
+
] = None,
|
|
101
|
+
instructions: Annotated[
|
|
102
|
+
str | None, "Additional instructions to use for the scrape (i.e specific fields or information to extract)."
|
|
103
|
+
] = None,
|
|
104
|
+
) -> ScrapeResponse:
|
|
105
|
+
"""Scrape the current page data"""
|
|
106
|
+
session_id = get_session_id()
|
|
107
|
+
data = notte.sessions.page.scrape(session_id=session_id, url=url, instructions=instructions, use_llm=True)
|
|
108
|
+
assert session is not None
|
|
109
|
+
return ScrapeResponse(
|
|
110
|
+
data=data,
|
|
111
|
+
session=session,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@mcp.tool(
|
|
116
|
+
description="Take an action on the current page. Use `notte_observe` first to list the available actions. Then use this tool to take an action. Don't hallucinate any action not listed in the observation."
|
|
117
|
+
)
|
|
118
|
+
def notte_step(
|
|
119
|
+
action_id: Annotated[str, "The ID of the action to execute. Use `notte_observe` to list the available actions."],
|
|
120
|
+
value: Annotated[
|
|
121
|
+
str | None,
|
|
122
|
+
"The value to input for form actions. Only to be provider for interactions actions (i.e ID starts with `I`, e.g. `I0`, `I1`, etc.)",
|
|
123
|
+
] = None,
|
|
124
|
+
) -> ObserveResponse:
|
|
125
|
+
"""Take an action on the current page"""
|
|
126
|
+
session_id = get_session_id()
|
|
127
|
+
obs = notte.sessions.page.step(session_id=session_id, action_id=action_id, value=value)
|
|
128
|
+
obs.screenshot = None
|
|
129
|
+
assert session is not None
|
|
130
|
+
return ObserveResponse.from_obs(obs, session=session)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@mcp.tool(description="Run an `Notte` agent/operator to complete a given task on any website")
|
|
134
|
+
def notte_operator(
|
|
135
|
+
task: Annotated[str, "The task to complete"],
|
|
136
|
+
url: Annotated[str | None, "The URL to complete the task on (optional)"] = None,
|
|
137
|
+
vizualize_in_browser: Annotated[
|
|
138
|
+
bool,
|
|
139
|
+
"Whether to visualize the agent's work in the browser (should only be set to True if explicitely requested by the user otherwise set it to False by default)",
|
|
140
|
+
] = False,
|
|
141
|
+
) -> str:
|
|
142
|
+
"""Run an agent asynchronously"""
|
|
143
|
+
agent = notte.agents.start(task=task, url=url)
|
|
144
|
+
if vizualize_in_browser:
|
|
145
|
+
notte.sessions.viewer(session_id=agent.session_id)
|
|
146
|
+
# wait for the agent to finish
|
|
147
|
+
response = notte.agents.wait(agent.agent_id)
|
|
148
|
+
if response.success:
|
|
149
|
+
assert response.answer is not None
|
|
150
|
+
return response.answer
|
|
151
|
+
else:
|
|
152
|
+
return "Failed to run agent. Try to be better specify the task and url."
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if __name__ == "__main__":
|
|
156
|
+
# mcp.run(transport="sse")
|
|
157
|
+
mcp.run(transport="stdio")
|