Skip to content

Commit 381846e

Browse files
authored
Improve documentation (#14)
1 parent 2013bad commit 381846e

File tree

4 files changed

+139
-48
lines changed

4 files changed

+139
-48
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Contributing to `mcp-shell` <!-- omit from toc -->
1+
# Contributing to Model Context Shell <!-- omit from toc -->
22

3-
First off, thank you for taking the time to contribute to MCP Shell! :+1: :tada: MCP Shell is released under the Apache 2.0 license.
3+
First off, thank you for taking the time to contribute to Model Context Shell! :+1: :tada: Model Context Shell is released under the Apache 2.0 license.
44
If you would like to contribute something or want to hack on the code, this
55
document should help you get started. You can find some hints for starting
6-
development in mcp-shell's
7-
[README](https://github.com/StacklokLabs/mcp-shell/blob/main/README.md).
6+
development in the project's
7+
[README](https://github.com/StacklokLabs/model-context-shell/blob/main/README.md).
88

99
## Table of contents <!-- omit from toc -->
1010

@@ -19,17 +19,17 @@ development in mcp-shell's
1919
## Code of conduct
2020

2121
This project adheres to the
22-
[Contributor Covenant](https://github.com/StacklokLabs/mcp-shell/blob/main/CODE_OF_CONDUCT.md)
22+
[Contributor Covenant](https://github.com/StacklokLabs/model-context-shell/blob/main/CODE_OF_CONDUCT.md)
2323
code of conduct. By participating, you are expected to uphold this code. Please
2424
report unacceptable behavior to
2525
[code-of-conduct@stacklok.com](mailto:code-of-conduct@stacklok.com).
2626

2727
## Reporting security vulnerabilities
2828

29-
If you think you have found a security vulnerability in mcp-shell please DO
29+
If you think you have found a security vulnerability in Model Context Shell please DO
3030
NOT disclose it publicly until we've had a chance to fix it. Please don't report
3131
security vulnerabilities using GitHub issues; instead, please follow this
32-
[process](https://github.com/StacklokLabs/mcp-shell/blob/main/SECURITY.md)
32+
[process](https://github.com/StacklokLabs/model-context-shell/blob/main/SECURITY.md)
3333

3434
## How to contribute
3535

@@ -46,7 +46,7 @@ sample project that reproduces the problem.
4646
### Not sure how to start contributing?
4747

4848
PRs to resolve existing issues are greatly appreciated and issues labeled as
49-
["good first issue"](https://github.com/StacklokLabs/mcp-shell/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
49+
["good first issue"](https://github.com/StacklokLabs/model-context-shell/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
5050
are a great place to start!
5151

5252
### Pull request process
@@ -56,15 +56,15 @@ are a great place to start!
5656
of Origin. For additional details, check out the [DCO instructions](dco.md).
5757

5858
- Create an issue outlining the fix or feature.
59-
- Fork the mcp-shell repository to your own GitHub account and clone it
59+
- Fork the repository to your own GitHub account and clone it
6060
locally.
6161
- Hack on your changes.
6262
- Correctly format your commit messages, see
6363
[Commit message guidelines](#commit-message-guidelines) below.
6464
- Open a PR by ensuring the title and its description reflect the content of the
6565
PR.
6666
- Ensure that CI passes, if it fails, fix the failures.
67-
- Every pull request requires a review from the core mcp-shell team before
67+
- Every pull request requires a review from the core team before
6868
merging.
6969
- Once approved, all of your commits will be squashed into a single commit with
7070
your PR title.

README.md

Lines changed: 126 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,55 @@
1-
# MCP Shell
1+
# Model Context Shell
22

3-
**Unix-style pipelines for MCP tools — coordinate thousands of tool calls in a single request**
3+
[![CI](https://github.com/StacklokLabs/model-context-shell/actions/workflows/ci.yml/badge.svg)](https://github.com/StacklokLabs/model-context-shell/actions/workflows/ci.yml)
4+
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
45

5-
## Overview
6+
**Unix-style pipelines for MCP tools — compose complex tool workflows as single pipeline requests**
67

7-
MCP Shell is an MCP server that lets AI agents compose tool calls using Unix shell patterns. Instead of the agent orchestrating each tool call individually (loading all intermediate data into context), agents can express complex workflows as pipelines that execute server-side.
8+
## Introduction
89

9-
```bash
10-
# What agents can express:
11-
fetch https://api.example.com/users \
12-
| jq -c '.[] | .profile_url' \
13-
| for_each fetch \
14-
| jq '[.[] | select(.active)] | sort_by(.name)'
15-
```
10+
Model Context Shell is a system that lets AI agents compose [MCP](https://modelcontextprotocol.io/) tool calls similar to Unix shell scripting. Instead of the agent orchestrating each tool call individually (loading all intermediate data into context), agents can express complex workflows as pipelines that execute server-side.
1611

17-
This single pipeline fetches a list, extracts URLs, fetches each one, filters the results, and returns only the final output to the agent — no intermediate data in context.
12+
For example, an agent can express a multi-step workflow as a single pipeline:
1813

19-
## Why This Matters
14+
```mermaid
15+
flowchart LR
16+
A["Fetch users (MCP)"] --> B["Extract profile URLs (Shell)"] --> C["for_each (Shell)"] --> C1["Fetch profile (MCP)"] --> D["Filter and sort (Shell)"]
17+
```
2018

21-
MCP is great — standardized interfaces, structured data, extensible ecosystem. But for complex workflows, agents hit real limits:
19+
This pipeline fetches a list, extracts URLs, fetches each one, filters the results, and returns only the final output to the agent — no intermediate data in context.
20+
21+
### Why this matters
22+
23+
[MCP](https://modelcontextprotocol.io/) is great — standardized interfaces, structured data, extensible ecosystem. But for complex workflows, the agent has to orchestrate each tool call individually, loading all intermediate results into context. Model Context Shell adds a pipeline layer — the agent sends a single pipeline, and the server coordinates the tools, returning only the final result:
24+
25+
```mermaid
26+
flowchart LR
27+
subgraph without["Standard Workflow"]
28+
direction TB
29+
A1[Agent]
30+
A1 <--> T1a[Tool A]
31+
A1 <--> T2a[Tool B]
32+
A1 <--> T3a[Tool C]
33+
end
34+
subgraph with["Model Context Shell"]
35+
direction TB
36+
A2[Agent] <--> S[Shell]
37+
S --> T1b[Tool A] --> S
38+
S --> T2b[Tool B] --> S
39+
S --> T3b[Tool C] --> S
40+
end
41+
without ~~~ with
42+
```
2243

23-
| | Without MCP Shell | With MCP Shell |
44+
| | Without | With |
2445
|---|---|---|
2546
| **Orchestration** | Agent coordinates every tool call, loading intermediate results into context | Single pipeline request, only final result returned |
26-
| **Composition** | Tools combined through LLM reasoning | Native Unix-style piping between tools |
47+
| **Composition** | Tools combined by the agent one call at a time | Native Unix-style piping between tools |
2748
| **Data scale** | Limited by context window | Streaming/iterator model handles datasets larger than memory |
2849
| **Reliability** | LLM-dependent control flow | Deterministic shell pipeline execution |
2950
| **Permissions** | Complex tasks push toward full shell access | Sandboxed execution with allowed commands only |
3051

31-
## Real-World Example
52+
### Real-world example
3253

3354
Example query: "List all Pokemon over 50 kg that have the chlorophyll ability"
3455

@@ -38,15 +59,68 @@ Instead of 7+ separate tool calls loading all Pokemon data into context, the age
3859
- Fetched each Pokemon's details (7 API calls)
3960
- Filtered by weight and formatted the results
4061

41-
**Result**: 50%+ reduction in tokens and only the final answer loaded into context.
62+
**Result**: Only the final answer is loaded into context — no intermediate API responses.
63+
64+
In practice, agents don't construct the perfect pipeline on the first try. They typically run a few exploratory queries first to understand the shape of the data before building the final pipeline. To keep this process fast and cheap, the server includes a preview stage powered by [headson](https://github.com/kantord/headson) that returns a compact structural summary of the data — enough for the agent to plan its transformations without loading the full dataset into context.
65+
66+
### Design
67+
68+
Agents already have access to full shell environments and can call any CLI tool, which has significant overlap with what MCP tools provide. Rather than duplicating that, Model Context Shell explores whether similar workflows can be achieved in a safer, simpler MCP-native environment. Patterns like parallel map-reduce over tool call results are not common today because MCP doesn't natively support them, but they seem like a natural fit for coordinating tool calls — imagine fetching all console errors via a Chrome DevTools MCP server and creating a separate GitHub issue for each one. A system tailored to these patterns can make them first-class operations.
69+
70+
The execution engine works with JSON pipeline definitions directly — agents construct pipelines from the MCP tool schema alone, without needing shell syntax. Commands are never passed through a shell interpreter; each command and its arguments are passed as separate elements to the underlying process (`shell=False`), eliminating shell injection risks entirely. Data flows between stages as JSON, preserving types through the pipeline rather than reducing everything to strings. MCP tool arguments are validated against their JSON Schema by the receiving server, giving agents type-checked feedback when they construct pipelines incorrectly.
71+
72+
The result is a more constrained system compared to a general-purpose shell — only a fixed set of data transformation commands is available, and all execution happens inside a container.
73+
74+
### How it works
75+
76+
Model Context Shell is packaged as an MCP server, which makes it easy to use with any agent that supports the protocol. It could also be packaged as a library built directly into an agent.
77+
78+
The server exposes four tools to the agent via MCP:
79+
80+
| Tool | Purpose |
81+
|---|---|
82+
| `execute_pipeline` | Execute a pipeline of tool calls and shell commands |
83+
| `list_all_tools` | Discover all tools available from MCP servers via [ToolHive](https://stacklok.com/download/) |
84+
| `get_tool_details` | Get the full schema and description for a specific tool |
85+
| `list_available_shell_commands` | Show the whitelist of allowed CLI commands |
86+
87+
The agent constructs pipelines as JSON arrays of stages. Data flows from one stage to the next, similar to Unix pipes. There are three stage types:
88+
89+
**Tool stages** call external MCP tools discovered through ToolHive:
90+
```json
91+
{"type": "tool", "name": "fetch", "server": "fetch", "args": {"url": "https://..."}}
92+
```
93+
94+
**Command stages** transform data using whitelisted shell commands:
95+
```json
96+
{"type": "command", "command": "jq", "args": ["-c", ".results[] | {id, name}"]}
97+
```
98+
99+
**Preview stages** show a summarized view of the data at any point in the pipeline, useful for the agent to understand the data structure before writing transformations:
100+
```json
101+
{"type": "preview", "chars": 3000}
102+
```
42103

43-
## Installation
104+
Any tool stage can set `"for_each": true` to process items one-by-one. The preceding stage must output JSONL (one JSON object per line), and the tool is called once per line. Results are collected into an array. This enables patterns like "fetch a list of URLs, then fetch each one" in a single pipeline call, using a single reused connection for efficiency.
105+
106+
Here is a full example — a pipeline that fetches users, extracts their profile URLs, fetches each profile, and filters for active users:
107+
108+
```json
109+
[
110+
{"type": "tool", "name": "fetch", "server": "fetch", "args": {"url": "https://api.example.com/users"}},
111+
{"type": "command", "command": "jq", "args": ["-c", ".[] | {url: .profile_url}"]},
112+
{"type": "tool", "name": "fetch", "server": "fetch", "for_each": true},
113+
{"type": "command", "command": "jq", "args": ["-c", "[.[] | select(.active)] | sort_by(.name)"]}
114+
]
115+
```
116+
117+
## Setup
44118

45119
### Prerequisites
46120

47-
- [ToolHive](https://toolhive.ai) (`thv`) for running and managing MCP servers
121+
- [ToolHive](https://stacklok.com/download/) (`thv`) — a runtime for managing MCP servers
48122

49-
### Quick Start
123+
### Quick start
50124

51125
Run the pre-built image from GitHub Container Registry:
52126

@@ -58,36 +132,52 @@ thv run ghcr.io/stackloklabs/model-context-shell:latest --network host --foregro
58132
thv run ghcr.io/stackloklabs/model-context-shell:latest --foreground --transport streamable-http
59133
```
60134

61-
Once running, MCP Shell is available to any AI agent that ToolHive supports — no additional integration required.
135+
Once running, Model Context Shell is available to any AI agent that ToolHive supports — no additional integration required. It works with any existing MCP servers running through ToolHive, and relies on ToolHive's authentication model for connected servers.
136+
137+
### Tips
138+
139+
**Connect only Model Context Shell to your agent** — For best results, don't connect individual MCP servers directly to the agent alongside Model Context Shell. When agents have direct access to tools, they may call them individually instead of composing efficient pipelines. The server can access all your MCP servers through ToolHive automatically.
140+
141+
**Some agents need encouragement** — Most agents will use the shell naturally for complex tasks, but some may need a hint in their system prompt (e.g., "Use Model Context Shell pipelines to combine multiple tool calls efficiently").
62142

63143
## Security
64144

65-
MCP Shell runs in a containerized environment through ToolHive, so commands have no direct access to the user's filesystem — only through explicitly configured MCP servers.
145+
ToolHive runs Model Context Shell in an isolated container, so shell commands have no access to the host filesystem or network. The MCP servers it coordinates also run in their own separate containers, managed by ToolHive.
146+
147+
- **Allowed commands only**: A fixed whitelist of safe, read-only data transformation commands (`jq`, `grep`, `sed`, `awk`, `sort`, `uniq`, `cut`, `wc`, `head`, `tail`, `tr`, `date`, `bc`, `paste`, `shuf`, `join`, `sleep`)
148+
- **No shell injection**: Commands are executed with `shell=False`, arguments passed separately
149+
- **MCP tools only**: All external operations go through approved MCP servers
66150

67-
- **Containerized**: Runs isolated from the host system
68-
- **Allowed Commands**: Only safe, read-only data transformation commands are permitted
69-
- **No Shell Injection**: Commands are executed with `shell=False`, args passed separately
70-
- **MCP Tools Only**: All external operations go through approved MCP servers
151+
## Development
71152

72-
## Usage Tips
153+
### Requirements
73154

74-
**Connect only MCP Shell to your agent** — For best results, don't connect individual MCP servers directly to the agent alongside MCP Shell. When agents have direct access to tools, they may call them individually instead of composing efficient pipelines. MCP Shell can access all your MCP servers through ToolHive automatically.
155+
- Python 3.13+
156+
- [uv](https://docs.astral.sh/uv/) for dependency management
75157

76-
**Some agents need encouragement** — Most agents will use the shell naturally for complex tasks, but some may need a hint in their system prompt (e.g., "Use MCP Shell pipelines to combine multiple tool calls efficiently").
158+
### Setup
77159

78-
## FAQ
160+
```bash
161+
uv sync --group dev
162+
```
79163

80-
**Q: Does this work with my existing MCP servers?**
164+
### Running tests
81165

82-
A: Yes! MCP Shell coordinates any standard MCP servers running through ToolHive.
166+
```bash
167+
uv run pytest
168+
```
83169

84-
**Q: What about authentication?**
170+
### Linting and type checking
85171

86-
A: Currently relies on ToolHive's authentication model for connected MCP servers.
172+
```bash
173+
uv run ruff check .
174+
uv run ruff format --check .
175+
uv run pyright
176+
```
87177

88178
## Contributing
89179

90-
This is an experimental project. Contributions, ideas, and feedback are welcome!
180+
Contributions, ideas, and feedback are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines, including our DCO sign-off requirement.
91181

92182
## License
93183

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ your contributions.
77
## Reporting a vulnerability
88

99
To report a security issue, please use the GitHub Security Advisory
10-
["Report a Vulnerability"](https://github.com/StacklokLabs/mcp-shell/security/advisories/new)
10+
["Report a Vulnerability"](https://github.com/StacklokLabs/model-context-shell/security/advisories/new)
1111
tab.
1212

1313
If you are unable to access GitHub you can also email us at
@@ -80,7 +80,7 @@ These steps should be completed within the 1-7 days of Disclosure.
8080
- Create a new
8181
[security advisory](https://docs.github.com/en/code-security/security-advisories/)
8282
in affected repository by visiting
83-
`https://github.com/StacklokLabs/mcp-shell/security/advisories/new`
83+
`https://github.com/StacklokLabs/model-context-shell/security/advisories/new`
8484
- As many details as possible should be entered such as versions affected, CVE
8585
(if available yet). As more information is discovered, edit and update the
8686
advisory accordingly.

mcp-metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"tools": [
99
"execute_pipeline",
1010
"list_all_tools",
11+
"get_tool_details",
1112
"list_available_shell_commands"
1213
],
1314
"metadata": {

0 commit comments

Comments
 (0)