moodle-study-kit 0.1.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.
- moodle_study_kit-0.1.0/LICENSE +21 -0
- moodle_study_kit-0.1.0/MANIFEST.in +6 -0
- moodle_study_kit-0.1.0/PKG-INFO +194 -0
- moodle_study_kit-0.1.0/README.md +169 -0
- moodle_study_kit-0.1.0/pyproject.toml +33 -0
- moodle_study_kit-0.1.0/setup.cfg +4 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit/__init__.py +65 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit/cli.py +390 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit/client.py +161 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit/config.py +133 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit/deadlines.py +101 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit/extraction.py +386 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit/materials.py +225 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit/mcp_server.py +165 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit/summaries.py +1311 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit.egg-info/PKG-INFO +194 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit.egg-info/SOURCES.txt +26 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit.egg-info/dependency_links.txt +1 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit.egg-info/entry_points.txt +2 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit.egg-info/requires.txt +10 -0
- moodle_study_kit-0.1.0/src/moodle_study_kit.egg-info/top_level.txt +1 -0
- moodle_study_kit-0.1.0/tests/test_cli.py +279 -0
- moodle_study_kit-0.1.0/tests/test_client.py +88 -0
- moodle_study_kit-0.1.0/tests/test_config.py +136 -0
- moodle_study_kit-0.1.0/tests/test_deadlines.py +83 -0
- moodle_study_kit-0.1.0/tests/test_extraction.py +397 -0
- moodle_study_kit-0.1.0/tests/test_materials.py +376 -0
- moodle_study_kit-0.1.0/tests/test_summaries.py +1270 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yamin Mushtaq
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: moodle-study-kit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Read-only Moodle toolkit for agents, MCP servers, and local scripts
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Keywords: moodle,lms,education,study,mcp
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Topic :: Education
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Provides-Extra: pdf
|
|
18
|
+
Requires-Dist: pymupdf>=1.23; extra == "pdf"
|
|
19
|
+
Provides-Extra: mcp
|
|
20
|
+
Requires-Dist: mcp>=1.0; extra == "mcp"
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
23
|
+
Requires-Dist: pymupdf>=1.23; extra == "dev"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# moodle-study-kit
|
|
27
|
+
|
|
28
|
+
Read-only Moodle toolkit for students and agents. Provides a Python library, CLI, and MCP server for accessing Moodle course data without any write operations.
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Clone and install
|
|
34
|
+
git clone <repo-url> && cd moodle-study-kit
|
|
35
|
+
python -m venv .venv && source .venv/bin/activate
|
|
36
|
+
pip install -e '.[dev]'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Windows note:** If `moodle-study` is not recognised after installation, the Python
|
|
40
|
+
Scripts folder isn't on your PATH. Either:
|
|
41
|
+
|
|
42
|
+
1. Add it manually — find the path with:
|
|
43
|
+
```
|
|
44
|
+
py -c "import site; print(site.getUserSitePackages())"
|
|
45
|
+
```
|
|
46
|
+
Then add it to your PATH in **Windows Settings > System > Environment Variables**.
|
|
47
|
+
|
|
48
|
+
2. OR use the module form as a workaround (works immediately, no PATH needed):
|
|
49
|
+
```
|
|
50
|
+
py -m moodle_study_kit.cli courses
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Run guided setup
|
|
55
|
+
moodle-study setup
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The setup command will prompt for your Moodle URL, API token, and user ID, then verify the connection and save credentials to `~/.config/moodle-study-kit/config.json`.
|
|
59
|
+
|
|
60
|
+
## Getting a Moodle API token
|
|
61
|
+
|
|
62
|
+
1. Log in to your Moodle site in a browser.
|
|
63
|
+
2. Go to **Site administration > Plugins > Web services > Manage tokens**, or ask your Moodle admin for a web-service token.
|
|
64
|
+
3. If your institution uses the **Moodle mobile app**, you may already have a token. Check your Moodle mobile app settings or use the Moodle mobile web-service endpoint:
|
|
65
|
+
```
|
|
66
|
+
https://<your-moodle>/login/token.php?username=YOUR_USER&password=YOUR_PASS&service=moodle_mobile_app
|
|
67
|
+
```
|
|
68
|
+
**Note:** Only use this over HTTPS. Never share your token.
|
|
69
|
+
4. Copy the token for use in setup.
|
|
70
|
+
|
|
71
|
+
## Configuration
|
|
72
|
+
|
|
73
|
+
Credentials are resolved in this order:
|
|
74
|
+
|
|
75
|
+
1. **Explicit arguments** passed to `MoodleConfig.load(url=..., token=...)`
|
|
76
|
+
2. **Environment variables**: `MOODLE_URL`, `MOODLE_TOKEN`, `MOODLE_USERID`
|
|
77
|
+
3. **Config file** (first found):
|
|
78
|
+
- `$MOODLE_CREDS_PATH` (if set)
|
|
79
|
+
- `~/.config/moodle-study-kit/config.json`
|
|
80
|
+
- `~/.moodle_creds.json`
|
|
81
|
+
|
|
82
|
+
### Config file format
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"url": "https://moodle.example.ac.uk",
|
|
87
|
+
"token": "your_token_here",
|
|
88
|
+
"userid": 12345
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Environment variables
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
export MOODLE_URL="https://moodle.example.ac.uk"
|
|
96
|
+
export MOODLE_TOKEN="your_token_here"
|
|
97
|
+
export MOODLE_USERID="12345"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## CLI usage
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
moodle-study courses # List enrolled courses
|
|
104
|
+
moodle-study deadlines # Show upcoming deadlines (14-day window)
|
|
105
|
+
moodle-study deadlines --days 7 # Shorter look-ahead
|
|
106
|
+
moodle-study contents 12345 # Show sections for course ID 12345
|
|
107
|
+
moodle-study contents EC100 # Look up by course short-code
|
|
108
|
+
moodle-study contents MG488 # Prefix match: finds MG488_2526 if unique
|
|
109
|
+
moodle-study materials EC100 # Discover all downloadable materials
|
|
110
|
+
moodle-study materials EC100 --week 3 # Materials for week 3 only
|
|
111
|
+
moodle-study setup # Guided first-time setup
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Add `--json` before the command for machine-readable JSON output:
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
moodle-study --json courses
|
|
118
|
+
moodle-study --json deadlines
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## MCP server
|
|
122
|
+
|
|
123
|
+
For use with Claude Code, OpenClaw, or other MCP-capable agents:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pip install -e "moodle-study-kit[mcp]"
|
|
127
|
+
python -m moodle_study_kit.mcp_server
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The server runs as a stdio-based MCP server. Tools: `list_courses`, `get_deadlines`, `get_course_contents`, `get_week_materials`, `search_course_content`, `get_weekly_summary`.
|
|
131
|
+
|
|
132
|
+
**Claude Code**: Add to your Claude Code settings / MCP Servers config:
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"mcpServers": {
|
|
136
|
+
"moodle-study-kit": {
|
|
137
|
+
"command": "python",
|
|
138
|
+
"args": ["-m", "moodle_study_kit.mcp_server"]
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
Set `MOODLE_URL`, `MOODLE_TOKEN`, `MOODLE_USERID` as environment variables or in `~/.config/moodle-study-kit/config.json`.
|
|
144
|
+
|
|
145
|
+
**OpenClaw**: Add to your agent or gateway config:
|
|
146
|
+
```yaml
|
|
147
|
+
mcpServers:
|
|
148
|
+
moodle:
|
|
149
|
+
command: python
|
|
150
|
+
args: ["-m", "moodle_study_kit.mcp_server"]
|
|
151
|
+
env:
|
|
152
|
+
MOODLE_URL: "https://your-moodle.example.ac.uk"
|
|
153
|
+
MOODLE_TOKEN: "your_token_here"
|
|
154
|
+
MOODLE_USERID: "12345"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Running tests
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
pip install -e '.[dev]'
|
|
161
|
+
pytest
|
|
162
|
+
|
|
163
|
+
# On Windows, if pytest isn't found on PATH:
|
|
164
|
+
py -m pytest
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Safety
|
|
168
|
+
|
|
169
|
+
This package is **read-only by design**. Every Moodle API call is checked against a hardcoded allowlist in `ALLOWED_FUNCTIONS` inside the client module. Write-like operations — submitting assignments, posting forum replies, uploading files, creating events, deleting content — are blocked with a `SafetyError` before any network request is made.
|
|
170
|
+
|
|
171
|
+
- Your token cannot modify anything on Moodle, even accidentally.
|
|
172
|
+
- Agents (Claude Code, OpenClaw, etc.) can use these tools safely.
|
|
173
|
+
- Treat your Moodle API token like a password: never commit it to git, never share it, use HTTPS only.
|
|
174
|
+
|
|
175
|
+
### Known limitations
|
|
176
|
+
|
|
177
|
+
- **Token portability varies by institution.** Some Moodle instances require specific web-service configurations. Check with your Moodle administrator about enabling REST web services.
|
|
178
|
+
- **Rate limiting.** Moodle servers may throttle rapid API calls. The package handles errors gracefully but cannot bypass institutional limits.
|
|
179
|
+
- **Only Moodle REST API v2 is supported.**
|
|
180
|
+
- **Course discovery by short-code uses prefix matching** (e.g. "MG488" matches "MG488_2526") — see CLI usage above.
|
|
181
|
+
|
|
182
|
+
## For Agent Authors
|
|
183
|
+
|
|
184
|
+
moodle-study-kit is designed to be agent-friendly:
|
|
185
|
+
|
|
186
|
+
- Zero configuration needed for discovery — call `list_courses()` with no arguments to explore.
|
|
187
|
+
- Self-documenting tool names and clear purpose descriptions.
|
|
188
|
+
- Structured output by default — use `--json` on CLI, or rely on structured dict/JSON from the Python API.
|
|
189
|
+
- Graceful degradation with clear error messages when credentials are missing.
|
|
190
|
+
|
|
191
|
+
Example integration in an agent system prompt:
|
|
192
|
+
```
|
|
193
|
+
You have access to moodle-study-kit. First run list_courses() to see available courses, then get_deadlines() to check upcoming work, then explore specific courses with get_course_contents().
|
|
194
|
+
```
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# moodle-study-kit
|
|
2
|
+
|
|
3
|
+
Read-only Moodle toolkit for students and agents. Provides a Python library, CLI, and MCP server for accessing Moodle course data without any write operations.
|
|
4
|
+
|
|
5
|
+
## Quick start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Clone and install
|
|
9
|
+
git clone <repo-url> && cd moodle-study-kit
|
|
10
|
+
python -m venv .venv && source .venv/bin/activate
|
|
11
|
+
pip install -e '.[dev]'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**Windows note:** If `moodle-study` is not recognised after installation, the Python
|
|
15
|
+
Scripts folder isn't on your PATH. Either:
|
|
16
|
+
|
|
17
|
+
1. Add it manually — find the path with:
|
|
18
|
+
```
|
|
19
|
+
py -c "import site; print(site.getUserSitePackages())"
|
|
20
|
+
```
|
|
21
|
+
Then add it to your PATH in **Windows Settings > System > Environment Variables**.
|
|
22
|
+
|
|
23
|
+
2. OR use the module form as a workaround (works immediately, no PATH needed):
|
|
24
|
+
```
|
|
25
|
+
py -m moodle_study_kit.cli courses
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Run guided setup
|
|
30
|
+
moodle-study setup
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The setup command will prompt for your Moodle URL, API token, and user ID, then verify the connection and save credentials to `~/.config/moodle-study-kit/config.json`.
|
|
34
|
+
|
|
35
|
+
## Getting a Moodle API token
|
|
36
|
+
|
|
37
|
+
1. Log in to your Moodle site in a browser.
|
|
38
|
+
2. Go to **Site administration > Plugins > Web services > Manage tokens**, or ask your Moodle admin for a web-service token.
|
|
39
|
+
3. If your institution uses the **Moodle mobile app**, you may already have a token. Check your Moodle mobile app settings or use the Moodle mobile web-service endpoint:
|
|
40
|
+
```
|
|
41
|
+
https://<your-moodle>/login/token.php?username=YOUR_USER&password=YOUR_PASS&service=moodle_mobile_app
|
|
42
|
+
```
|
|
43
|
+
**Note:** Only use this over HTTPS. Never share your token.
|
|
44
|
+
4. Copy the token for use in setup.
|
|
45
|
+
|
|
46
|
+
## Configuration
|
|
47
|
+
|
|
48
|
+
Credentials are resolved in this order:
|
|
49
|
+
|
|
50
|
+
1. **Explicit arguments** passed to `MoodleConfig.load(url=..., token=...)`
|
|
51
|
+
2. **Environment variables**: `MOODLE_URL`, `MOODLE_TOKEN`, `MOODLE_USERID`
|
|
52
|
+
3. **Config file** (first found):
|
|
53
|
+
- `$MOODLE_CREDS_PATH` (if set)
|
|
54
|
+
- `~/.config/moodle-study-kit/config.json`
|
|
55
|
+
- `~/.moodle_creds.json`
|
|
56
|
+
|
|
57
|
+
### Config file format
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"url": "https://moodle.example.ac.uk",
|
|
62
|
+
"token": "your_token_here",
|
|
63
|
+
"userid": 12345
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Environment variables
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
export MOODLE_URL="https://moodle.example.ac.uk"
|
|
71
|
+
export MOODLE_TOKEN="your_token_here"
|
|
72
|
+
export MOODLE_USERID="12345"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## CLI usage
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
moodle-study courses # List enrolled courses
|
|
79
|
+
moodle-study deadlines # Show upcoming deadlines (14-day window)
|
|
80
|
+
moodle-study deadlines --days 7 # Shorter look-ahead
|
|
81
|
+
moodle-study contents 12345 # Show sections for course ID 12345
|
|
82
|
+
moodle-study contents EC100 # Look up by course short-code
|
|
83
|
+
moodle-study contents MG488 # Prefix match: finds MG488_2526 if unique
|
|
84
|
+
moodle-study materials EC100 # Discover all downloadable materials
|
|
85
|
+
moodle-study materials EC100 --week 3 # Materials for week 3 only
|
|
86
|
+
moodle-study setup # Guided first-time setup
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Add `--json` before the command for machine-readable JSON output:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
moodle-study --json courses
|
|
93
|
+
moodle-study --json deadlines
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## MCP server
|
|
97
|
+
|
|
98
|
+
For use with Claude Code, OpenClaw, or other MCP-capable agents:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install -e "moodle-study-kit[mcp]"
|
|
102
|
+
python -m moodle_study_kit.mcp_server
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The server runs as a stdio-based MCP server. Tools: `list_courses`, `get_deadlines`, `get_course_contents`, `get_week_materials`, `search_course_content`, `get_weekly_summary`.
|
|
106
|
+
|
|
107
|
+
**Claude Code**: Add to your Claude Code settings / MCP Servers config:
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"mcpServers": {
|
|
111
|
+
"moodle-study-kit": {
|
|
112
|
+
"command": "python",
|
|
113
|
+
"args": ["-m", "moodle_study_kit.mcp_server"]
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
Set `MOODLE_URL`, `MOODLE_TOKEN`, `MOODLE_USERID` as environment variables or in `~/.config/moodle-study-kit/config.json`.
|
|
119
|
+
|
|
120
|
+
**OpenClaw**: Add to your agent or gateway config:
|
|
121
|
+
```yaml
|
|
122
|
+
mcpServers:
|
|
123
|
+
moodle:
|
|
124
|
+
command: python
|
|
125
|
+
args: ["-m", "moodle_study_kit.mcp_server"]
|
|
126
|
+
env:
|
|
127
|
+
MOODLE_URL: "https://your-moodle.example.ac.uk"
|
|
128
|
+
MOODLE_TOKEN: "your_token_here"
|
|
129
|
+
MOODLE_USERID: "12345"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Running tests
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
pip install -e '.[dev]'
|
|
136
|
+
pytest
|
|
137
|
+
|
|
138
|
+
# On Windows, if pytest isn't found on PATH:
|
|
139
|
+
py -m pytest
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Safety
|
|
143
|
+
|
|
144
|
+
This package is **read-only by design**. Every Moodle API call is checked against a hardcoded allowlist in `ALLOWED_FUNCTIONS` inside the client module. Write-like operations — submitting assignments, posting forum replies, uploading files, creating events, deleting content — are blocked with a `SafetyError` before any network request is made.
|
|
145
|
+
|
|
146
|
+
- Your token cannot modify anything on Moodle, even accidentally.
|
|
147
|
+
- Agents (Claude Code, OpenClaw, etc.) can use these tools safely.
|
|
148
|
+
- Treat your Moodle API token like a password: never commit it to git, never share it, use HTTPS only.
|
|
149
|
+
|
|
150
|
+
### Known limitations
|
|
151
|
+
|
|
152
|
+
- **Token portability varies by institution.** Some Moodle instances require specific web-service configurations. Check with your Moodle administrator about enabling REST web services.
|
|
153
|
+
- **Rate limiting.** Moodle servers may throttle rapid API calls. The package handles errors gracefully but cannot bypass institutional limits.
|
|
154
|
+
- **Only Moodle REST API v2 is supported.**
|
|
155
|
+
- **Course discovery by short-code uses prefix matching** (e.g. "MG488" matches "MG488_2526") — see CLI usage above.
|
|
156
|
+
|
|
157
|
+
## For Agent Authors
|
|
158
|
+
|
|
159
|
+
moodle-study-kit is designed to be agent-friendly:
|
|
160
|
+
|
|
161
|
+
- Zero configuration needed for discovery — call `list_courses()` with no arguments to explore.
|
|
162
|
+
- Self-documenting tool names and clear purpose descriptions.
|
|
163
|
+
- Structured output by default — use `--json` on CLI, or rely on structured dict/JSON from the Python API.
|
|
164
|
+
- Graceful degradation with clear error messages when credentials are missing.
|
|
165
|
+
|
|
166
|
+
Example integration in an agent system prompt:
|
|
167
|
+
```
|
|
168
|
+
You have access to moodle-study-kit. First run list_courses() to see available courses, then get_deadlines() to check upcoming work, then explore specific courses with get_course_contents().
|
|
169
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "moodle-study-kit"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Read-only Moodle toolkit for agents, MCP servers, and local scripts"
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
keywords = ["moodle", "lms", "education", "study", "mcp"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Operating System :: OS Independent",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.10",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Topic :: Education",
|
|
21
|
+
]
|
|
22
|
+
dependencies = []
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
pdf = ["pymupdf>=1.23"]
|
|
26
|
+
mcp = ["mcp>=1.0"]
|
|
27
|
+
dev = ["pytest>=7.0", "pymupdf>=1.23"]
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
moodle-study = "moodle_study_kit.cli:main"
|
|
31
|
+
|
|
32
|
+
[tool.setuptools.packages.find]
|
|
33
|
+
where = ["src"]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""moodle-study-kit — Read-only Moodle toolkit."""
|
|
2
|
+
|
|
3
|
+
from moodle_study_kit.client import (
|
|
4
|
+
ALLOWED_FUNCTIONS,
|
|
5
|
+
BLOCKED_PATTERNS,
|
|
6
|
+
MoodleClient,
|
|
7
|
+
MoodleWriteAttemptError,
|
|
8
|
+
)
|
|
9
|
+
from moodle_study_kit.config import DEFAULT_CONFIG_PATH, MoodleConfig, test_connection
|
|
10
|
+
from moodle_study_kit.deadlines import get_upcoming_deadlines
|
|
11
|
+
from moodle_study_kit.extraction import (
|
|
12
|
+
FILE_PRIORITY,
|
|
13
|
+
SUPPORTED_EXTENSIONS,
|
|
14
|
+
clean_text,
|
|
15
|
+
extract_file_text,
|
|
16
|
+
is_boilerplate,
|
|
17
|
+
strip_html,
|
|
18
|
+
)
|
|
19
|
+
from moodle_study_kit.materials import (
|
|
20
|
+
extract_materials,
|
|
21
|
+
get_section_materials,
|
|
22
|
+
match_section,
|
|
23
|
+
search_course_content,
|
|
24
|
+
)
|
|
25
|
+
from moodle_study_kit.summaries import (
|
|
26
|
+
build_deterministic_summary,
|
|
27
|
+
build_summary,
|
|
28
|
+
classify_section,
|
|
29
|
+
fallback_bullets,
|
|
30
|
+
find_best_section,
|
|
31
|
+
format_bullets,
|
|
32
|
+
get_downloadable_files,
|
|
33
|
+
score_section_match,
|
|
34
|
+
summarize_modules,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
"ALLOWED_FUNCTIONS",
|
|
39
|
+
"BLOCKED_PATTERNS",
|
|
40
|
+
"DEFAULT_CONFIG_PATH",
|
|
41
|
+
"FILE_PRIORITY",
|
|
42
|
+
"MoodleClient",
|
|
43
|
+
"MoodleConfig",
|
|
44
|
+
"MoodleWriteAttemptError",
|
|
45
|
+
"SUPPORTED_EXTENSIONS",
|
|
46
|
+
"build_deterministic_summary",
|
|
47
|
+
"build_summary",
|
|
48
|
+
"classify_section",
|
|
49
|
+
"clean_text",
|
|
50
|
+
"extract_file_text",
|
|
51
|
+
"extract_materials",
|
|
52
|
+
"fallback_bullets",
|
|
53
|
+
"find_best_section",
|
|
54
|
+
"format_bullets",
|
|
55
|
+
"get_downloadable_files",
|
|
56
|
+
"get_section_materials",
|
|
57
|
+
"get_upcoming_deadlines",
|
|
58
|
+
"is_boilerplate",
|
|
59
|
+
"match_section",
|
|
60
|
+
"score_section_match",
|
|
61
|
+
"search_course_content",
|
|
62
|
+
"strip_html",
|
|
63
|
+
"summarize_modules",
|
|
64
|
+
"test_connection",
|
|
65
|
+
]
|