docker-tiny-mcp 0.1.0__py3-none-any.whl

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.
Files changed (45) hide show
  1. docker_tiny_mcp/__init__.py +1 -0
  2. docker_tiny_mcp/__main__.py +280 -0
  3. docker_tiny_mcp/consent.py +252 -0
  4. docker_tiny_mcp/daemon.py +71 -0
  5. docker_tiny_mcp/errors.py +89 -0
  6. docker_tiny_mcp/events.py +51 -0
  7. docker_tiny_mcp/models.py +444 -0
  8. docker_tiny_mcp/prompts.py +58 -0
  9. docker_tiny_mcp/resources/__init__.py +15 -0
  10. docker_tiny_mcp/resources/containers.py +13 -0
  11. docker_tiny_mcp/resources/images.py +13 -0
  12. docker_tiny_mcp/resources/info.py +13 -0
  13. docker_tiny_mcp/resources/templates/__init__.py +11 -0
  14. docker_tiny_mcp/resources/templates/container.py +13 -0
  15. docker_tiny_mcp/resources/templates/logs.py +14 -0
  16. docker_tiny_mcp/safety.py +156 -0
  17. docker_tiny_mcp/server.py +115 -0
  18. docker_tiny_mcp/tools/__init__.py +57 -0
  19. docker_tiny_mcp/tools/container.py +104 -0
  20. docker_tiny_mcp/tools/containers.py +44 -0
  21. docker_tiny_mcp/tools/create.py +210 -0
  22. docker_tiny_mcp/tools/events.py +65 -0
  23. docker_tiny_mcp/tools/exec.py +99 -0
  24. docker_tiny_mcp/tools/images.py +71 -0
  25. docker_tiny_mcp/tools/info.py +51 -0
  26. docker_tiny_mcp/tools/logs.py +101 -0
  27. docker_tiny_mcp/tools/networks.py +59 -0
  28. docker_tiny_mcp/tools/prune.py +60 -0
  29. docker_tiny_mcp/tools/pull.py +36 -0
  30. docker_tiny_mcp/tools/read.py +69 -0
  31. docker_tiny_mcp/tools/remove.py +36 -0
  32. docker_tiny_mcp/tools/remove_image.py +37 -0
  33. docker_tiny_mcp/tools/restart.py +31 -0
  34. docker_tiny_mcp/tools/results.py +50 -0
  35. docker_tiny_mcp/tools/start.py +36 -0
  36. docker_tiny_mcp/tools/stats.py +124 -0
  37. docker_tiny_mcp/tools/stop.py +28 -0
  38. docker_tiny_mcp/tools/volumes.py +56 -0
  39. docker_tiny_mcp/tools/wait.py +57 -0
  40. docker_tiny_mcp/tools/write.py +76 -0
  41. docker_tiny_mcp-0.1.0.dist-info/METADATA +424 -0
  42. docker_tiny_mcp-0.1.0.dist-info/RECORD +45 -0
  43. docker_tiny_mcp-0.1.0.dist-info/WHEEL +4 -0
  44. docker_tiny_mcp-0.1.0.dist-info/entry_points.txt +3 -0
  45. docker_tiny_mcp-0.1.0.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,51 @@
1
+ """Relay Docker events as resource notifications."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import asyncio
6
+ import logging
7
+
8
+ from aiodocker import Docker
9
+ from aiodocker.exceptions import DockerError
10
+ from aiohttp_tiny_mcp import Registry
11
+ from aiohttp_tiny_mcp.storage.hub import NOTIFICATIONS, topic
12
+
13
+ log = logging.getLogger(__name__)
14
+
15
+
16
+ async def publish(registry: Registry, uri: str) -> None:
17
+ await registry.hub.publish(
18
+ topic(NOTIFICATIONS),
19
+ {
20
+ "jsonrpc": "2.0",
21
+ "method": "notifications/resources/updated",
22
+ "params": {"uri": uri},
23
+ },
24
+ )
25
+
26
+
27
+ async def relay(registry: Registry, client: Docker) -> None:
28
+ """Publish one notification per container event. Runs until cancelled."""
29
+ subscriber = client.events.subscribe()
30
+ while True:
31
+ event = await subscriber.get()
32
+ if event is None:
33
+ return
34
+ if event.get("Type") != "container":
35
+ continue
36
+ await publish(registry, "docker://containers")
37
+ identity = (event.get("Actor") or {}).get("ID")
38
+ if identity:
39
+ await publish(registry, f"docker://containers/{identity[:12]}")
40
+
41
+
42
+ async def watch(registry: Registry, client: Docker) -> None:
43
+ """Reconnect the event relay when the daemon disconnects."""
44
+ while True:
45
+ try:
46
+ await relay(registry, client)
47
+ except asyncio.CancelledError:
48
+ raise
49
+ except (DockerError, OSError):
50
+ log.warning("event stream lost, reconnecting", exc_info=True)
51
+ await asyncio.sleep(1)
@@ -0,0 +1,444 @@
1
+ """Tool argument and result models. Results report truncation and observed post-action state."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Annotated, Any, Literal
6
+
7
+ from pydantic import BaseModel, ConfigDict, Field, StringConstraints
8
+
9
+ Stream = Literal["stdout", "stderr"]
10
+
11
+
12
+ class Nothing(BaseModel):
13
+ """No arguments."""
14
+
15
+
16
+ class ContainerFilter(BaseModel):
17
+ all: bool = Field(
18
+ False,
19
+ description="Include stopped containers. False lists only running ones.",
20
+ )
21
+ name: str | None = Field(
22
+ None,
23
+ description="Keep only containers whose name contains this text.",
24
+ )
25
+ limit: int = Field(50, ge=1, le=500, description="Most containers to return.")
26
+
27
+
28
+ class ContainerRef(BaseModel):
29
+ container: str = Field(
30
+ description="Container name or id. A short id prefix is enough.",
31
+ )
32
+
33
+
34
+ class ContainerName(BaseModel):
35
+ """Arguments supplied by docker://containers/{name} templates."""
36
+
37
+ name: str
38
+
39
+
40
+ class StopRequest(ContainerRef):
41
+ seconds: int = Field(10, ge=0, le=600, description="How long to wait before killing it.")
42
+
43
+
44
+ class RemoveRequest(ContainerRef):
45
+ force: bool = Field(False, description="Remove it even while it runs.")
46
+ volumes: bool = Field(False, description="Remove its anonymous volumes too.")
47
+
48
+
49
+ class LogRequest(ContainerRef):
50
+ lines: int = Field(100, ge=1, le=5000, description="How many last lines to read.")
51
+ stream: Literal["both", "stdout", "stderr"] = Field("both", description="Which stream to read.")
52
+ since: str | None = Field(
53
+ None,
54
+ description=(
55
+ "Read only what was written after this time. Pass the `cursor` of "
56
+ "an earlier read to see what is new since then."
57
+ ),
58
+ )
59
+ contains: str | None = Field(
60
+ None, description="Keep only lines holding this text. Case is ignored."
61
+ )
62
+
63
+
64
+ class ExecRequest(ContainerRef):
65
+ command: list[str] = Field(
66
+ description='The command and its arguments, already split: ["ls", "-la", "/"].',
67
+ )
68
+ seconds: int = Field(
69
+ 30,
70
+ ge=1,
71
+ le=600,
72
+ description="How long to let it run before giving up on it.",
73
+ )
74
+ workdir: str | None = Field(None, description="Directory to run it in.")
75
+ user: str | None = Field(None, description='Who to run it as, such as "postgres".')
76
+
77
+
78
+ class ReadRequest(ContainerRef):
79
+ path: str = Field(description="Absolute path of the file inside the container.")
80
+
81
+
82
+ class WriteRequest(ContainerRef):
83
+ path: str = Field(description="Absolute path to write, inside the container.")
84
+ content: str = Field(description="What the file is to hold. It replaces what is there.")
85
+ mode: str = Field("644", description="Permission bits, as three or four octal digits.")
86
+
87
+
88
+ class FileContent(BaseModel):
89
+ """File bytes read through the archive API, including from stopped containers."""
90
+
91
+ container: str
92
+ path: str
93
+ size_bytes: int
94
+ text: str
95
+ truncated: bool = Field(False, description="True where the file was too large to return.")
96
+ binary: bool = Field(False, description="True where this is not text. `text` is then empty.")
97
+
98
+
99
+ class Written(BaseModel):
100
+ container: str
101
+ path: str
102
+ size_bytes: int
103
+ note: str | None = None
104
+
105
+
106
+ class CreateOptions(BaseModel):
107
+ """Container creation options; only image is required."""
108
+
109
+ image: str = Field(description='Image to run, such as "redis:7-alpine".')
110
+ name: str | None = Field(None, description="What to call it. Docker invents one otherwise.")
111
+ command: list[str] | None = Field(
112
+ None,
113
+ description="What to run instead of the image's own command, already split.",
114
+ )
115
+ environment: dict[str, str] = Field(
116
+ default_factory=dict, description="Variables to set inside it."
117
+ )
118
+ ports: list[str] = Field(
119
+ default_factory=list,
120
+ description='Ports to publish, as "host:container" or "host:container/udp".',
121
+ )
122
+ volumes: list[str] = Field(
123
+ default_factory=list,
124
+ description='Paths to mount, as "/on/host:/in/container" or with ":ro" appended.',
125
+ )
126
+ restart: Literal["no", "on-failure", "always", "unless-stopped"] = Field(
127
+ "no", description="Whether the daemon starts it again after it stops."
128
+ )
129
+ workdir: str | None = Field(None, description="Directory its command starts in.")
130
+ user: str | None = Field(None, description="Who its command runs as.")
131
+ pull: Literal["missing", "always", "never"] = Field(
132
+ "missing", description="When to download the image first."
133
+ )
134
+ start: bool = Field(True, description="Start it once created.")
135
+
136
+
137
+ class CreateRequest(CreateOptions):
138
+ network: str | None = Field(None, description="Network to join. Otherwise the default one.")
139
+
140
+
141
+ class FixedNetworkCreateRequest(CreateOptions):
142
+ model_config = ConfigDict(extra="forbid")
143
+
144
+
145
+ NamedVolume = Annotated[
146
+ str,
147
+ StringConstraints(pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_.-]*:/[^:\x00\r\n]+(?::ro|:rw)?$"),
148
+ ]
149
+
150
+
151
+ class UnprivilegedCreateRequest(FixedNetworkCreateRequest):
152
+ volumes: list[NamedVolume] = Field(
153
+ default_factory=list,
154
+ description=(
155
+ 'Named volumes only: "data:/data" or "data:/data:ro". '
156
+ "Missing volumes are created with the local driver. Host paths are forbidden."
157
+ ),
158
+ )
159
+
160
+
161
+ class WaitRequest(ContainerRef):
162
+ state: Literal["running", "exited", "healthy"] = Field(
163
+ description="What to wait for it to become."
164
+ )
165
+ seconds: int = Field(30, ge=1, le=600, description="How long to wait before giving up.")
166
+
167
+
168
+ class ImageFilter(BaseModel):
169
+ reference: str | None = Field(
170
+ None, description='Keep only images matching this, such as "postgres*".'
171
+ )
172
+ unused: bool = Field(
173
+ False, description="Keep only images no container uses. What is safe to remove."
174
+ )
175
+
176
+
177
+ class ImageRef(BaseModel):
178
+ image: str = Field(description='Image name, tag or id, such as "redis:7-alpine".')
179
+ force: bool = Field(
180
+ False, description="Remove it although a stopped container still refers to it."
181
+ )
182
+
183
+
184
+ class PullRequest(BaseModel):
185
+ image: str = Field(description='Image to pull, such as "redis:7-alpine".')
186
+
187
+
188
+ class PruneRequest(BaseModel):
189
+ what: Literal["containers", "images", "volumes", "networks"] = Field(
190
+ description="Which kind of unused thing to remove."
191
+ )
192
+ dangling_only: bool = Field(
193
+ True,
194
+ description=(
195
+ "For images: remove only untagged ones. False removes every image "
196
+ "no container uses, which is far more."
197
+ ),
198
+ )
199
+
200
+
201
+ class FixedNetworkPruneRequest(PruneRequest):
202
+ model_config = ConfigDict(extra="forbid")
203
+
204
+ what: Literal["containers", "images", "volumes"] = Field(
205
+ description="Which kind of unused thing to remove."
206
+ )
207
+
208
+
209
+ class NameFilter(BaseModel):
210
+ name: str | None = Field(None, description="Keep only those whose name contains this text.")
211
+
212
+
213
+ class EventFilter(BaseModel):
214
+ seconds: int = Field(
215
+ 300, ge=1, le=86_400, description="How far back to look, in seconds from now."
216
+ )
217
+ container: str | None = Field(None, description="Keep only events about this container.")
218
+ limit: int = Field(100, ge=1, le=1000, description="Most events to return, newest last.")
219
+
220
+
221
+ class Container(BaseModel):
222
+ """One container, as much as is worth knowing without asking again."""
223
+
224
+ id: str = Field(description="Short id, twelve characters.")
225
+ name: str
226
+ image: str
227
+ state: str = Field(description="running, exited, paused, created, restarting or dead.")
228
+ status: str = Field(description="Human wording, such as 'Up 3 hours'.")
229
+ ports: list[str] = Field(default_factory=list, description="Published ports.")
230
+
231
+
232
+ class Containers(BaseModel):
233
+ containers: list[Container]
234
+ shown: int = Field(description="How many are listed here.")
235
+ total: int = Field(description="How many matched, before the limit.")
236
+
237
+
238
+ class ContainerDetail(BaseModel):
239
+ """Container inspect details; unlike list data, inspect has no human-readable status field."""
240
+
241
+ id: str = Field(description="Short id, twelve characters.")
242
+ name: str
243
+ image: str
244
+ state: str = Field(description="running, exited, paused, created, restarting or dead.")
245
+ ports: list[str] = Field(default_factory=list, description="Published ports.")
246
+ created: str = Field(description="When it was created, ISO-8601.")
247
+ started: str | None = Field(None, description="When it last started, ISO-8601.")
248
+ finished: str | None = Field(None, description="When it last stopped, ISO-8601.")
249
+ command: str = Field(description="What it runs, quoted as a shell would.")
250
+ restart_count: int
251
+ restart_policy: str = Field("no", description="What the daemon does after it stops.")
252
+ health: str | None = Field(None, description="healthy, unhealthy, starting, or absent.")
253
+ exit_code: int | None = Field(None, description="Set once it has stopped.")
254
+ error: str | None = None
255
+ compose: str | None = Field(
256
+ None,
257
+ description='Its place in a Compose project, as "project/service", where it has one.',
258
+ )
259
+ networks: list[str] = Field(default_factory=list)
260
+ mounts: list[str] = Field(default_factory=list, description="Source:destination pairs.")
261
+ environment: list[str] = Field(
262
+ default_factory=list, description="Names only. Values are not reported."
263
+ )
264
+
265
+
266
+ class Image(BaseModel):
267
+ id: str
268
+ tags: list[str]
269
+ size_mb: float
270
+ created: str = Field(description="When it was built, ISO-8601.")
271
+ used_by: list[str] = Field(
272
+ default_factory=list,
273
+ description="Containers holding it, running or not. Empty means safe to remove.",
274
+ )
275
+
276
+
277
+ class Images(BaseModel):
278
+ images: list[Image]
279
+ total: int
280
+ reclaimable_mb: float = Field(0.0, description="Size of the listed images no container uses.")
281
+
282
+
283
+ class Network(BaseModel):
284
+ id: str
285
+ name: str
286
+ driver: str
287
+ scope: str
288
+ subnets: list[str] = Field(default_factory=list)
289
+ containers: list[str] = Field(default_factory=list, description="What is attached.")
290
+
291
+
292
+ class Networks(BaseModel):
293
+ networks: list[Network]
294
+ total: int
295
+
296
+
297
+ class Volume(BaseModel):
298
+ name: str
299
+ driver: str
300
+ mountpoint: str
301
+ created: str | None = None
302
+ used_by: list[str] = Field(
303
+ default_factory=list, description="Containers mounting it. Empty means safe to remove."
304
+ )
305
+
306
+
307
+ class Volumes(BaseModel):
308
+ volumes: list[Volume]
309
+ total: int
310
+
311
+
312
+ class LogLine(BaseModel):
313
+ """Internal timestamped stream line used to merge stdout and stderr."""
314
+
315
+ at: str | None = None
316
+ stream: Stream
317
+ text: str
318
+
319
+ def rendered(self, *, tagged: bool) -> str:
320
+ """Render a log line as text."""
321
+ stamp = f"{self.at} " if self.at else ""
322
+ mark = f"{'err' if self.stream == 'stderr' else 'out'} " if tagged else ""
323
+ return f"{stamp}{mark}{self.text}"
324
+
325
+
326
+ class Logs(BaseModel):
327
+ container: str
328
+ lines: list[str] = Field(
329
+ description=(
330
+ 'One line each, written as "<time> <text>". Where both streams '
331
+ 'were read, the stream stands between them: "<time> err <text>".'
332
+ )
333
+ )
334
+ shown: int = Field(description="How many lines are here.")
335
+ truncated: bool = Field(description="True where older lines were left out.")
336
+ cursor: str | None = Field(
337
+ None,
338
+ description="Time of the last line. Pass it as `since` to read only what follows.",
339
+ )
340
+
341
+
342
+ class Executed(BaseModel):
343
+ """Command output and exit status, with stdout and stderr kept separate."""
344
+
345
+ container: str
346
+ command: str
347
+ exit_code: int = Field(description="Zero is success. -1 means it never ran.")
348
+ stdout: str
349
+ stderr: str
350
+ truncated: bool = Field(False, description="True where the output was too long to return.")
351
+ timed_out: bool = Field(
352
+ False,
353
+ description="True where it outlasted `seconds`. It may still be running inside.",
354
+ )
355
+
356
+
357
+ class Done(BaseModel):
358
+ """Observed state after an action, including exit code and notes on unexpected outcomes."""
359
+
360
+ container: str
361
+ action: str
362
+ state: str = Field(description="The state it is in now.")
363
+ exit_code: int | None = Field(None, description="Set where it is stopped.")
364
+ health: str | None = Field(None, description="healthy, unhealthy, starting, or absent.")
365
+ note: str | None = Field(None, description="What went differently, where anything did.")
366
+
367
+
368
+ class Created(BaseModel):
369
+ id: str = Field(description="Short id, twelve characters.")
370
+ name: str
371
+ image: str
372
+ state: str
373
+ ports: list[str] = Field(default_factory=list)
374
+ warnings: list[str] = Field(default_factory=list, description="What the daemon objected to.")
375
+ note: str | None = None
376
+
377
+
378
+ class Stats(BaseModel):
379
+ """Current resource use, with rates calculated from two counter samples."""
380
+
381
+ container: str
382
+ cpu_percent: float = Field(description="Of one core. 200 means two cores are busy.")
383
+ memory_mb: float
384
+ memory_limit_mb: float
385
+ memory_percent: float
386
+ net_rx_mb: float = Field(description="Received since it started.")
387
+ net_tx_mb: float = Field(description="Sent since it started.")
388
+ block_read_mb: float
389
+ block_write_mb: float
390
+ pids: int = Field(description="Processes running inside it.")
391
+
392
+
393
+ class Event(BaseModel):
394
+ at: str = Field(description="When it happened, ISO-8601.")
395
+ kind: str = Field(description="container, image, network, volume or daemon.")
396
+ action: str = Field(description="start, die, destroy, pull, and so on.")
397
+ subject: str = Field(description="Name of what it happened to.")
398
+ exit_code: int | None = Field(None, description="Set on a container that died.")
399
+
400
+
401
+ class Events(BaseModel):
402
+ events: list[Event]
403
+ shown: int
404
+ total: int = Field(description="How many matched, before the limit.")
405
+
406
+
407
+ class Pruned(BaseModel):
408
+ what: str
409
+ removed: list[str] = Field(default_factory=list)
410
+ reclaimed_mb: float
411
+
412
+
413
+ class Info(BaseModel):
414
+ """The daemon itself."""
415
+
416
+ endpoint: str = Field(description="Where this server found it.")
417
+ version: str
418
+ api_version: str
419
+ os: str
420
+ architecture: str
421
+ containers_running: int
422
+ containers_total: int
423
+ images: int
424
+
425
+
426
+ def short(value: str) -> str:
427
+ """Twelve characters of an id, the length Docker's own output uses."""
428
+ return value[:12]
429
+
430
+
431
+ def port_list(raw: Any) -> list[str]:
432
+ """Published ports, as one readable string each."""
433
+ published: list[str] = []
434
+ for port in raw or []:
435
+ if not isinstance(port, dict):
436
+ continue
437
+ public = port.get("PublicPort")
438
+ private = port.get("PrivatePort")
439
+ kind = port.get("Type", "tcp")
440
+ if public:
441
+ published.append(f"{port.get('IP', '0.0.0.0')}:{public}->{private}/{kind}")
442
+ elif private:
443
+ published.append(f"{private}/{kind}")
444
+ return published
@@ -0,0 +1,58 @@
1
+ """Diagnostic prompts and completion for current container and image names."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from aiodocker import Docker
6
+ from aiohttp_tiny_mcp.protocol.models import CompleteParams
7
+
8
+ from docker_tiny_mcp import daemon
9
+
10
+ from .models import ContainerRef, Nothing
11
+
12
+
13
+ async def diagnose(args: ContainerRef) -> str:
14
+ """Work out why a container is unhealthy or keeps restarting."""
15
+ return (
16
+ f"Container {args.container} is not behaving. Work out why.\n\n"
17
+ "Start with `container` for its state, exit code, health and restart "
18
+ "count. Read `logs` for what it wrote before it stopped, and `events` "
19
+ "for whether this has happened before and how often. Where it is a "
20
+ "resource problem, `stats` says so; where it is a configuration "
21
+ "problem, `read` shows the file the program actually has. Check "
22
+ "whether the exit code and the last lines agree about the cause.\n\n"
23
+ "Report the cause, the evidence for it, and the smallest change that "
24
+ "would fix it. Say so plainly if the evidence does not settle it."
25
+ )
26
+
27
+
28
+ async def reclaim(args: Nothing) -> str:
29
+ """Work out what can safely be removed."""
30
+ return (
31
+ "Find what is taking space and what can go.\n\n"
32
+ "Ask `images` with `unused` for what no container holds, and read "
33
+ "`reclaimable_mb` for what that is worth. Ask `volumes` for those "
34
+ "nothing mounts, and `containers` with `all` for the stopped ones. A "
35
+ "volume nobody mounts is not always waste: read its name before "
36
+ "proposing it, because it may be a database whose container is "
37
+ "gone.\n\n"
38
+ "Propose what to remove and why, largest first, and name the tool for "
39
+ "each: `prune` for a whole kind at once, `remove_image` for one. Do "
40
+ "not remove anything: say what you would remove and let the person "
41
+ "decide."
42
+ )
43
+
44
+
45
+ async def complete(args: CompleteParams, client: Docker) -> list[str]:
46
+ """Read current container and image names for completion."""
47
+ typed = args.argument.value.lower()
48
+ if args.argument.name in ("container", "name"):
49
+ names = [
50
+ str(name).lstrip("/")
51
+ for raw in await daemon.containers(client, all=True)
52
+ for name in raw.get("Names") or []
53
+ ]
54
+ elif args.argument.name == "image":
55
+ names = [tag for raw in await daemon.images(client) for tag in raw.get("RepoTags") or []]
56
+ else:
57
+ return []
58
+ return sorted({name for name in names if typed in name.lower()})[:100]
@@ -0,0 +1,15 @@
1
+ """Fixed and templated Docker resources registered by server.py."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from . import templates
6
+ from .containers import containers
7
+ from .images import images
8
+ from .info import info
9
+
10
+ __all__ = [
11
+ "containers",
12
+ "images",
13
+ "info",
14
+ "templates",
15
+ ]
@@ -0,0 +1,13 @@
1
+ """All containers as context, including stopped containers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from aiodocker import Docker
6
+
7
+ from docker_tiny_mcp import tools
8
+ from docker_tiny_mcp.models import ContainerFilter, Containers, Nothing
9
+
10
+
11
+ async def containers(args: Nothing, client: Docker) -> Containers:
12
+ """Every container, running or not."""
13
+ return await tools.containers(ContainerFilter(all=True, limit=500), client)
@@ -0,0 +1,13 @@
1
+ """`docker://images` -- every image held locally."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from aiodocker import Docker
6
+
7
+ from docker_tiny_mcp import tools
8
+ from docker_tiny_mcp.models import ImageFilter, Images, Nothing
9
+
10
+
11
+ async def images(args: Nothing, client: Docker) -> Images:
12
+ """Every image held locally."""
13
+ return await tools.images(ImageFilter(), client)
@@ -0,0 +1,13 @@
1
+ """Daemon information exposed as a resource."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from aiodocker import Docker
6
+
7
+ from docker_tiny_mcp import tools
8
+ from docker_tiny_mcp.models import Info, Nothing
9
+
10
+
11
+ async def info(args: Nothing, client: Docker) -> Info:
12
+ """The daemon's version and how much it holds."""
13
+ return await tools.info(args, client)
@@ -0,0 +1,11 @@
1
+ """Resource templates with handler arguments supplied by URI variables."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .container import container
6
+ from .logs import logs
7
+
8
+ __all__ = [
9
+ "container",
10
+ "logs",
11
+ ]
@@ -0,0 +1,13 @@
1
+ """`docker://containers/{name}` -- one container in full."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from aiodocker import Docker
6
+
7
+ from docker_tiny_mcp import tools
8
+ from docker_tiny_mcp.models import ContainerDetail, ContainerName, ContainerRef
9
+
10
+
11
+ async def container(args: ContainerName, client: Docker) -> ContainerDetail:
12
+ """One container in full."""
13
+ return await tools.container(ContainerRef(container=args.name), client)
@@ -0,0 +1,14 @@
1
+ """A plain-text log attachment, limited to the last 200 lines."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from aiodocker import Docker
6
+
7
+ from docker_tiny_mcp import tools
8
+ from docker_tiny_mcp.models import ContainerName, LogRequest
9
+
10
+
11
+ async def logs(args: ContainerName, client: Docker) -> str:
12
+ """The last two hundred lines one container wrote."""
13
+ written = await tools.logs(LogRequest(container=args.name, lines=200), client)
14
+ return "\n".join(written.lines)