PTY MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PTY MCP ServerSpawn a new terminal and run 'npm install'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PTY MCP Server
pty-mcp is a Model Context Protocol (MCP) server designed to manage pseudo-terminal (PTY) sessions. Built with TypeScript and the Effect ecosystem, it provides a robust and type-safe interface for spawning, controlling, and interacting with terminal processes programmatically.
Features
Spawn Sessions: Create new PTY sessions with custom commands, arguments, and environment variables.
Interactive Control: Write data to stdin and read from stdout/stderr in real-time.
Session Management: List active sessions, monitor status, and terminate processes.
Effect Ecosystem: Leverages the power of the Effect library for error handling, concurrency, and resource management.
MCP Integration: Seamlessly exposes PTY capabilities to MCP-compliant clients.
Related MCP server: MCP (Model Context Protocol) Server
Installation
pnpm installUsage
Build
pnpm run buildStart Server
pnpm startTesting
pnpm run testAuthor
Ali Almahdi Digital Innovation Architect & AI Enthusiast
Crafting the future of technology at the intersection of AI and human experience.
Website: ali.ac
GitHub: @almahdi
X (Twitter): @alialmahdi
License
This project is licensed under the AGPL-3.0 License. See the LICENSE file for details.
Available Tools
5 toolspty_killADestructive
Terminates a PTY session and optionally cleans up its buffer.
Behavior:
If the session is running, it will be killed (status becomes "killed")
If cleanup=false (default), the session remains in the list with its output buffer intact
If cleanup=true, the session is removed entirely and the buffer is freed
Keeping sessions without cleanup allows you to compare logs between runs
Use cleanup=false if you might want to read the output later. Use cleanup=true when you're done with the session entirely.
To send Ctrl+C instead of killing, use pty_write with data="\x03"
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The PTY session ID (from pty_spawn) | |
| cleanup | No | Remove session and free buffer (default: false) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds significant behavioral context beyond annotations: it explains the status change to 'killed', the buffer retention/cleanup behavior, and the purpose of keeping sessions for log comparison. While annotations indicate destructiveHint=true, the description elaborates on what gets destroyed and under what conditions, providing valuable operational details.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with clear sections (Behavior, usage advice), front-loaded with the core purpose, and every sentence adds value without redundancy. The alternative tool mention is appropriately brief and directly relevant.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (destructive operation with behavioral nuances), rich annotations, and no output schema, the description provides complete context: it covers purpose, detailed behavior, parameter implications, usage guidelines, and alternatives. No significant gaps remain for agent understanding.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 100% schema description coverage, the baseline is 3. The description adds meaningful context about parameter semantics: it explains the default behavior (cleanup=false), the implications of cleanup=true (removes session entirely and frees buffer), and ties parameter choices to usage scenarios (e.g., 'Use cleanup=false if you might want to read the output later'). This goes beyond the schema's basic descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the specific action ('Terminates a PTY session') and resource ('PTY session'), distinguishing it from siblings like pty_write (for sending signals) and pty_list/pty_read (for inspection). The title being null doesn't affect this clarity.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit guidance on when to use this tool versus alternatives: it specifies to use cleanup=false for potential future output reading and cleanup=true for complete removal, and explicitly names pty_write as an alternative for sending Ctrl+C instead of killing. This covers both when/when-not scenarios and alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
pty_listADestructive
Lists all PTY sessions (active and exited).
Use this tool to:
See all running and exited PTY sessions
Get session IDs for use with other pty_* tools
Check the status and output line count of each session
Monitor which processes are still running
Sessions remain in the list after exit until explicitly cleaned up with pty_kill, allowing you to read their output logs.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds valuable behavioral context beyond annotations: it explains that sessions remain in the list after exit until cleaned up with pty_kill, and it details the tool's role in monitoring (e.g., 'Check the status and output line count'). However, it does not fully address the annotations' hints (e.g., destructiveHint: true is not explained, and openWorldHint: true implications are unclear). No contradiction with annotations exists, but more could be said about the destructive and non-idempotent aspects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and front-loaded with a clear purpose statement, followed by a bulleted list of use cases and additional context. Every sentence earns its place by providing specific guidance or clarifying behavior, with no redundant or vague information. It is appropriately sized for the tool's complexity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (no parameters, but involves session management) and lack of output schema, the description is mostly complete: it explains what the tool does, when to use it, and key behaviors like session persistence. However, it could better address the annotations (e.g., why destructiveHint is true) and provide more detail on output format or error handling, leaving minor gaps in full contextual coverage.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0 parameters and 100% schema description coverage, the baseline is high. The description adds no parameter-specific information (as there are none), but it effectively compensates by explaining the tool's output semantics (e.g., session IDs, status, output line count), which is valuable given the lack of an output schema. This enhances understanding beyond the empty input schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with specific verbs ('Lists all PTY sessions') and distinguishes it from siblings by specifying it includes 'active and exited' sessions. It explicitly mentions the resource (PTY sessions) and scope (all, including exited ones), making it highly specific and differentiated from other pty_* tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit usage guidelines with a bulleted list of when to use this tool (e.g., 'See all running and exited PTY sessions', 'Get session IDs for use with other pty_* tools'), and it implicitly distinguishes from alternatives by not overlapping with functions like pty_kill, pty_read, etc. It also clarifies that sessions remain listed until cleaned up with pty_kill, guiding when not to use this for cleanup.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
pty_readADestructive
Reads output from a PTY session's buffer.
The PTY maintains a rolling buffer of output lines. Use offset and limit to paginate through the output.
Two modes:
Standard mode (no pattern): Returns consecutive lines
Search mode (with pattern): Filters lines by regex, returns matches with line numbers
The buffer stores up to PTY_MAX_BUFFER_LINES (default: 50000) lines. Older lines are discarded when the limit is reached.
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The PTY session ID (from pty_spawn) | |
| offset | No | Line number to start reading from (0-based, defaults to 0) | |
| limit | No | Number of lines to read (defaults to 500) | |
| pattern | No | Regex pattern to filter lines (enables search mode) | |
| ignoreCase | No | Case-insensitive pattern matching (default: false) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations provide readOnlyHint=false, destructiveHint=true, etc., but the description adds valuable behavioral context beyond that: it explains the rolling buffer mechanism, buffer size limit (PTY_MAX_BUFFER_LINES), and that older lines are discarded, which clarifies the destructive nature. No contradiction with annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with the core purpose, followed by structured details (modes, buffer info) in bullet-like form. Every sentence adds value—no fluff—and it's appropriately sized for the tool's complexity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema and rich annotations, the description is mostly complete: it covers purpose, usage, behavior, and parameters. However, it lacks details on return format (e.g., what data structure is returned) and error handling, which could aid the agent further.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents all parameters well. The description adds some semantics by explaining the two modes (standard vs. search) and how offset/limit work for pagination, but this mostly reinforces rather than extends the schema details.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb ('Reads') and resource ('output from a PTY session's buffer'), specifying it accesses a rolling buffer. It distinguishes from siblings like pty_write (writes), pty_kill (terminates), pty_spawn (creates), and pty_list (lists sessions), making the purpose specific and differentiated.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context on when to use it (e.g., to paginate through output, with or without regex filtering) and mentions the buffer size limit, but does not explicitly state when not to use it or name alternatives among siblings (e.g., no comparison to pty_list for session info).
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
pty_spawnADestructive
Spawns a new PTY (pseudo-terminal) session that runs in the background.
Unlike synchronous bash commands, PTY sessions persist and allow you to:
Run long-running processes (dev servers, watch modes, etc.)
Send interactive input (including Ctrl+C, arrow keys, etc.)
Read output at any time
Manage multiple concurrent terminal sessions
Returns the session ID, which you can use with other pty_* tools.
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | The command to execute (e.g., 'npm', 'python', 'bash') | |
| args | No | Arguments to pass to the command | |
| workdir | No | Working directory (defaults to project root) | |
| env | No | Additional environment variables | |
| title | No | Human-readable name for the session | |
| description | Yes | Clear, concise 5-10 word description of what this command does | |
| notifyOnExit | No | Receive notification when process exits (default: false) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds valuable context beyond annotations: it explains that sessions 'persist and allow you to' run processes, send input, read output, and manage sessions, which clarifies the tool's interactive and persistent nature. Annotations indicate it's destructive (destructiveHint: true) and not read-only (readOnlyHint: false), which aligns with 'Spawns' implying creation, but the description doesn't explicitly warn about destructive effects like resource consumption or process management risks.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and front-loaded with the core purpose, followed by bullet points for key capabilities and a concluding sentence on the return value. Every sentence earns its place by providing essential information without redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of spawning interactive sessions and the lack of an output schema, the description is mostly complete: it explains the tool's purpose, usage, and return value. However, it could better address behavioral risks implied by annotations (e.g., destructive effects) and provide more detail on error handling or session limits.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 100% schema description coverage, the schema already documents all 7 parameters thoroughly. The description adds no specific parameter semantics beyond implying the command and args are for execution, and the session ID is returned for use with other tools, which is minimal added value.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the specific action ('Spawns a new PTY session') and resource ('pseudo-terminal session'), distinguishing it from sibling tools like pty_kill, pty_list, pty_read, and pty_write by focusing on creation rather than management or interaction with existing sessions.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly states when to use this tool ('Unlike synchronous bash commands') and provides clear alternatives for specific use cases (e.g., 'Run long-running processes', 'Send interactive input'), though it doesn't name sibling tools directly, the context implies they are for managing spawned sessions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
pty_writeADestructive
Sends input data to an active PTY session.
Use this tool to:
Type commands or text into an interactive terminal
Send special key sequences (Ctrl+C, Enter, arrow keys, etc.)
Respond to prompts in interactive programs
Common escape sequences:
Enter/newline: "\n" or "\r"
Ctrl+C (interrupt): "\x03"
Ctrl+D (EOF): "\x04"
Ctrl+Z (suspend): "\x1a"
Tab: "\t"
Arrow Up: "\x1b[A"
Arrow Down: "\x1b[B"
Arrow Right: "\x1b[C"
Arrow Left: "\x1b[D"
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The PTY session ID (from pty_spawn) | |
| data | Yes | Input string to send (supports escape sequences) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already indicate destructiveHint=true (mutation) and non-idempotent, but the description adds valuable context: it specifies the tool is for interactive terminal input, supports escape sequences for special keys, and provides concrete examples of common sequences. This goes beyond annotations by detailing practical behavior and input formatting.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with a clear opening sentence followed by bullet points and a reference table for escape sequences. It's appropriately sized for the tool's complexity, though the escape sequence table is somewhat lengthy but necessary for clarity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (interactive terminal input), no output schema, and rich annotations, the description is mostly complete. It covers purpose, usage, and input details but could benefit from mentioning error cases or dependencies (e.g., requires an active PTY session from pty_spawn).
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents both parameters. The description adds some value by explaining that 'data' supports escape sequences and providing examples, but it doesn't add significant meaning beyond what the schema provides (e.g., no details on 'id' format or data constraints).
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the specific action ('Sends input data') and resource ('to an active PTY session'), distinguishing it from siblings like pty_read (receives output) or pty_spawn (creates session). It explicitly identifies the tool's function as transmitting user input to an interactive terminal.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit usage scenarios with bullet points: typing commands/text, sending special key sequences, and responding to prompts. It implicitly distinguishes from pty_read (for reading output) and pty_spawn (for creating sessions), though it doesn't explicitly name alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
5 tool updates
v1.0.0- First observed
pty_kill - First observed
pty_list - First observed
pty_read - First observed
pty_spawn - First observed
pty_write
TDQS
Each tool has a clearly distinct purpose with no overlap: pty_spawn creates sessions, pty_list enumerates them, pty_write sends input, pty_read retrieves output, and pty_kill terminates sessions. The descriptions reinforce these distinct roles, making tool selection unambiguous for an agent.
All tools follow a consistent 'pty_' prefix with descriptive action suffixes (spawn, list, write, read, kill) in snake_case. This uniform pattern makes the tool set predictable and easy to navigate, with no deviations in naming conventions.
With 5 tools, this server is well-scoped for managing pseudo-terminal sessions. Each tool serves a clear, necessary function (create, list, input, output, destroy), providing complete lifecycle coverage without bloat or redundancy, which is ideal for the domain.
The tool set offers complete CRUD/lifecycle coverage for PTY management: spawn (create), list (read), write (update input), read (retrieve output), and kill (delete). There are no obvious gaps; agents can fully manage sessions from creation to termination with all necessary interactions.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A TypeScript MCP server for Home Assistant, enabling programmatic management of entities, automati…
A Model Context Protocol server for Wix AI tools
A simple Typescript MCP server built using the official MCP Typescript SDK and smithery/cli. This…
Related MCP Servers
- AlicenseAqualityCmaintenanceA Model Context Protocol server that enables AI assistants to interact with iTerm2 terminals, allowing creation and management of terminal sessions, command execution, and reading terminal output.53314ISC
- -licenseNot gradedqualityDmaintenanceA TypeScript implementation of a Model Context Protocol server and client that enables interaction with language models (specifically Mistral running on Ollama).-
- AlicenseCqualityCmaintenanceA Model Context Protocol server that enables clients to interact with a system terminal running in an Electron application, allowing for executing commands, managing terminal sessions, and retrieving output programmatically.55MIT
- -licenseAqualityNot gradedmaintenanceA comprehensive Node.js server implementing Model Context Protocol (MCP) that enables filesystem operations, process management, and terminal session handling with an enterprise-grade security approach.14668,809-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/almahdi/mcp-terminal'
If you have feedback or need assistance with the MCP directory API, please join our Discord server