@letta-ai/letta-code 0.14.7 → 0.14.9
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.
- package/letta.js +1205 -649
- package/package.json +2 -2
- package/skills/converting-mcps-to-skills/SKILL.md +171 -0
- package/skills/converting-mcps-to-skills/references/skill-templates.md +141 -0
- package/skills/converting-mcps-to-skills/scripts/mcp-http.ts +429 -0
- package/skills/converting-mcps-to-skills/scripts/mcp-stdio.ts +359 -0
- package/skills/converting-mcps-to-skills/scripts/package.json +13 -0
- package/vendor/ink/build/hooks/use-input.js +23 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@letta-ai/letta-code",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.9",
|
|
4
4
|
"description": "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"check": "bun run scripts/check.js",
|
|
63
63
|
"dev": "bun --loader:.md=text --loader:.mdx=text --loader:.txt=text run src/index.ts",
|
|
64
64
|
"build": "node scripts/postinstall-patches.js && bun run build.js",
|
|
65
|
-
"
|
|
65
|
+
"prepublishOnly": "bun run build",
|
|
66
66
|
"postinstall": "node scripts/postinstall-patches.js"
|
|
67
67
|
},
|
|
68
68
|
"lint-staged": {
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: converting-mcps-to-skills
|
|
3
|
+
description: Connect to MCP (Model Context Protocol) servers and create skills for repeated use. Load when a user wants to use an MCP server, connect to external tools via MCP, or when they mention MCP, model context protocol, or specific MCP servers.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Converting MCP Servers to Skills
|
|
7
|
+
|
|
8
|
+
Letta Code is not itself an MCP client, but as a general computer-use agent, you can easily connect to any MCP server using the scripts in this skill.
|
|
9
|
+
|
|
10
|
+
## What is MCP?
|
|
11
|
+
|
|
12
|
+
MCP (Model Context Protocol) is a standard for exposing tools to AI agents. MCP servers provide tools via JSON-RPC, either over:
|
|
13
|
+
- **HTTP** - Server running at a URL (e.g., `http://localhost:3001/mcp`)
|
|
14
|
+
- **stdio** - Server runs as a subprocess, communicating via stdin/stdout
|
|
15
|
+
|
|
16
|
+
## Quick Start: Connecting to an MCP Server
|
|
17
|
+
|
|
18
|
+
### Step 1: Determine the transport type
|
|
19
|
+
|
|
20
|
+
Ask the user:
|
|
21
|
+
- Is it an HTTP server (has a URL)?
|
|
22
|
+
- Is it a stdio server (runs via command like `npx`, `node`, `python`)?
|
|
23
|
+
|
|
24
|
+
### Step 2: Test the connection
|
|
25
|
+
|
|
26
|
+
**For HTTP servers:**
|
|
27
|
+
```bash
|
|
28
|
+
npx tsx <skill-path>/scripts/mcp-http.ts <url> list-tools
|
|
29
|
+
|
|
30
|
+
# With auth header
|
|
31
|
+
npx tsx <skill-path>/scripts/mcp-http.ts <url> --header "Authorization: Bearer KEY" list-tools
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**For stdio servers:**
|
|
35
|
+
```bash
|
|
36
|
+
# First, install dependencies (one time)
|
|
37
|
+
cd <skill-path>/scripts && npm install
|
|
38
|
+
|
|
39
|
+
# Then connect
|
|
40
|
+
npx tsx <skill-path>/scripts/mcp-stdio.ts "<command>" list-tools
|
|
41
|
+
|
|
42
|
+
# Examples
|
|
43
|
+
npx tsx <skill-path>/scripts/mcp-stdio.ts "npx -y @modelcontextprotocol/server-filesystem ." list-tools
|
|
44
|
+
npx tsx <skill-path>/scripts/mcp-stdio.ts "python server.py" list-tools
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Step 3: Explore available tools
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# List all tools
|
|
51
|
+
... list-tools
|
|
52
|
+
|
|
53
|
+
# Get schema for a specific tool
|
|
54
|
+
... info <tool-name>
|
|
55
|
+
|
|
56
|
+
# Test calling a tool
|
|
57
|
+
... call <tool-name> '{"arg": "value"}'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Creating a Dedicated Skill
|
|
61
|
+
|
|
62
|
+
When an MCP server will be used repeatedly, create a dedicated skill for it. This makes future use easier and documents the server's capabilities.
|
|
63
|
+
|
|
64
|
+
### Decision: Simple vs Rich Skill
|
|
65
|
+
|
|
66
|
+
**Simple skill** (just SKILL.md):
|
|
67
|
+
- Good for straightforward servers
|
|
68
|
+
- Documents how to use the parent skill's scripts with this specific server
|
|
69
|
+
- No additional scripts needed
|
|
70
|
+
|
|
71
|
+
**Rich skill** (SKILL.md + scripts/):
|
|
72
|
+
- Good for frequently-used servers
|
|
73
|
+
- Includes convenience wrapper scripts with defaults baked in
|
|
74
|
+
- Provides a simpler interface than the generic scripts
|
|
75
|
+
|
|
76
|
+
See `references/skill-templates.md` for templates.
|
|
77
|
+
|
|
78
|
+
## Built-in Scripts Reference
|
|
79
|
+
|
|
80
|
+
### mcp-http.ts - HTTP Transport
|
|
81
|
+
|
|
82
|
+
Connects to MCP servers over HTTP. No dependencies required.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx tsx mcp-http.ts <url> [options] <command> [args]
|
|
86
|
+
|
|
87
|
+
Commands:
|
|
88
|
+
list-tools List available tools
|
|
89
|
+
list-resources List available resources
|
|
90
|
+
info <tool> Show tool schema
|
|
91
|
+
call <tool> '<json>' Call a tool
|
|
92
|
+
|
|
93
|
+
Options:
|
|
94
|
+
--header "K: V" Add HTTP header (repeatable)
|
|
95
|
+
--timeout <ms> Request timeout (default: 30000)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Examples:**
|
|
99
|
+
```bash
|
|
100
|
+
# Basic usage
|
|
101
|
+
npx tsx mcp-http.ts http://localhost:3001/mcp list-tools
|
|
102
|
+
|
|
103
|
+
# With authentication
|
|
104
|
+
npx tsx mcp-http.ts http://localhost:3001/mcp --header "Authorization: Bearer KEY" list-tools
|
|
105
|
+
|
|
106
|
+
# Call a tool
|
|
107
|
+
npx tsx mcp-http.ts http://localhost:3001/mcp call vault '{"action":"search","query":"notes"}'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### mcp-stdio.ts - stdio Transport
|
|
111
|
+
|
|
112
|
+
Connects to MCP servers that run as subprocesses. Requires npm install first.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# One-time setup
|
|
116
|
+
cd <skill-path>/scripts && npm install
|
|
117
|
+
|
|
118
|
+
npx tsx mcp-stdio.ts "<command>" [options] <action> [args]
|
|
119
|
+
|
|
120
|
+
Actions:
|
|
121
|
+
list-tools List available tools
|
|
122
|
+
list-resources List available resources
|
|
123
|
+
info <tool> Show tool schema
|
|
124
|
+
call <tool> '<json>' Call a tool
|
|
125
|
+
|
|
126
|
+
Options:
|
|
127
|
+
--env "KEY=VALUE" Set environment variable (repeatable)
|
|
128
|
+
--cwd <path> Set working directory
|
|
129
|
+
--timeout <ms> Request timeout (default: 30000)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Examples:**
|
|
133
|
+
```bash
|
|
134
|
+
# Filesystem server
|
|
135
|
+
npx tsx mcp-stdio.ts "npx -y @modelcontextprotocol/server-filesystem ." list-tools
|
|
136
|
+
|
|
137
|
+
# With environment variable
|
|
138
|
+
npx tsx mcp-stdio.ts "node server.js" --env "API_KEY=xxx" list-tools
|
|
139
|
+
|
|
140
|
+
# Call a tool
|
|
141
|
+
npx tsx mcp-stdio.ts "python server.py" call read_file '{"path":"./README.md"}'
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Common MCP Servers
|
|
145
|
+
|
|
146
|
+
Here are some well-known MCP servers:
|
|
147
|
+
|
|
148
|
+
| Server | Transport | Command/URL |
|
|
149
|
+
|--------|-----------|-------------|
|
|
150
|
+
| Filesystem | stdio | `npx -y @modelcontextprotocol/server-filesystem <path>` |
|
|
151
|
+
| GitHub | stdio | `npx -y @modelcontextprotocol/server-github` |
|
|
152
|
+
| Brave Search | stdio | `npx -y @modelcontextprotocol/server-brave-search` |
|
|
153
|
+
| obsidian-mcp-plugin | HTTP | `http://localhost:3001/mcp` |
|
|
154
|
+
|
|
155
|
+
## Troubleshooting
|
|
156
|
+
|
|
157
|
+
**"Cannot connect" error:**
|
|
158
|
+
- For HTTP: Check the URL is correct and server is running
|
|
159
|
+
- For stdio: Check the command works when run directly in terminal
|
|
160
|
+
|
|
161
|
+
**"Authentication required" error:**
|
|
162
|
+
- Add `--header "Authorization: Bearer YOUR_KEY"` for HTTP
|
|
163
|
+
- Or `--env "API_KEY=xxx"` for stdio servers that need env vars
|
|
164
|
+
|
|
165
|
+
**stdio "npm install" error:**
|
|
166
|
+
- Run `cd <skill-path>/scripts && npm install` first
|
|
167
|
+
- The stdio client requires the MCP SDK
|
|
168
|
+
|
|
169
|
+
**Tool call fails:**
|
|
170
|
+
- Use `info <tool>` to see the expected input schema
|
|
171
|
+
- Ensure JSON arguments match the schema
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Skill Templates for MCP Servers
|
|
2
|
+
|
|
3
|
+
When to create a dedicated skill:
|
|
4
|
+
- **One-off use**: No skill needed - just use `converting-mcps-to-skills` scripts directly
|
|
5
|
+
- **Repeated use**: Create a self-contained skill with customized scripts
|
|
6
|
+
|
|
7
|
+
Skills should be self-contained per the [Agent Skills spec](https://agentskills.io/specification).
|
|
8
|
+
|
|
9
|
+
## Naming Rules (from Agent Skills spec)
|
|
10
|
+
|
|
11
|
+
The `name` field must:
|
|
12
|
+
- Be lowercase letters, numbers, and hyphens only (`a-z`, `0-9`, `-`)
|
|
13
|
+
- Be 1-64 characters
|
|
14
|
+
- Not start or end with a hyphen
|
|
15
|
+
- Not contain consecutive hyphens (`--`)
|
|
16
|
+
- Match the parent directory name exactly
|
|
17
|
+
|
|
18
|
+
Examples: `using-github-mcp`, `mcp-filesystem`, `slack-mcp`
|
|
19
|
+
|
|
20
|
+
## Skill Template
|
|
21
|
+
|
|
22
|
+
Use this template when creating a self-contained skill for an MCP server.
|
|
23
|
+
|
|
24
|
+
### Directory Structure
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
using-<server-name>/
|
|
28
|
+
├── SKILL.md
|
|
29
|
+
└── scripts/
|
|
30
|
+
└── <server>.ts # Customized client (copied from converting-mcps-to-skills)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### SKILL.md Template
|
|
34
|
+
|
|
35
|
+
```markdown
|
|
36
|
+
---
|
|
37
|
+
name: using-<server-name>
|
|
38
|
+
description: <What the server does>. Use when <trigger conditions>.
|
|
39
|
+
# Optional fields:
|
|
40
|
+
# license: MIT
|
|
41
|
+
# compatibility: Requires network access to <service>
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
# Using <Server Name>
|
|
45
|
+
|
|
46
|
+
<Brief description>
|
|
47
|
+
|
|
48
|
+
## Prerequisites
|
|
49
|
+
|
|
50
|
+
- <Requirements>
|
|
51
|
+
|
|
52
|
+
## Quick Start
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Set API key (if needed)
|
|
56
|
+
export <SERVER>_API_KEY="your-key"
|
|
57
|
+
|
|
58
|
+
# List tools
|
|
59
|
+
npx tsx <skill-path>/scripts/<server>.ts list-tools
|
|
60
|
+
|
|
61
|
+
# Call a tool
|
|
62
|
+
npx tsx <skill-path>/scripts/<server>.ts call <tool> '{"arg":"value"}'
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Available Tools
|
|
66
|
+
|
|
67
|
+
<Document tools with examples>
|
|
68
|
+
|
|
69
|
+
## Environment Variables
|
|
70
|
+
|
|
71
|
+
- `<SERVER>_API_KEY` - API key for authentication
|
|
72
|
+
- `<SERVER>_URL` - Override server URL (default: <default-url>)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Script Template (scripts/<server>.ts)
|
|
76
|
+
|
|
77
|
+
Copy the HTTP client from `converting-mcps-to-skills/scripts/mcp-http.ts` (or `mcp-stdio.ts` for stdio servers) and customize:
|
|
78
|
+
|
|
79
|
+
1. Set `DEFAULT_URL` to this server's URL
|
|
80
|
+
2. Rename the API key env var (e.g., `GITHUB_MCP_KEY` instead of generic)
|
|
81
|
+
3. Optionally simplify the CLI for common operations
|
|
82
|
+
|
|
83
|
+
The copied code is self-contained - no external dependencies for HTTP transport.
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
#!/usr/bin/env npx tsx
|
|
87
|
+
/**
|
|
88
|
+
* <Server Name> CLI - Self-contained MCP client
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
// Customize these for your server
|
|
92
|
+
const DEFAULT_URL = "<server-url>";
|
|
93
|
+
const API_KEY = process.env.<SERVER>_API_KEY;
|
|
94
|
+
|
|
95
|
+
// Copy the rest of mcp-http.ts here and adjust as needed
|
|
96
|
+
// ...
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Example: Self-Contained Filesystem Skill
|
|
100
|
+
|
|
101
|
+
A complete example of a self-contained skill for the MCP filesystem server:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
using-mcp-filesystem/
|
|
105
|
+
├── SKILL.md
|
|
106
|
+
└── scripts/
|
|
107
|
+
└── filesystem.ts # Copied and customized from mcp-stdio.ts
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**SKILL.md:**
|
|
111
|
+
```markdown
|
|
112
|
+
---
|
|
113
|
+
name: using-mcp-filesystem
|
|
114
|
+
description: Access local filesystem via MCP. Use when user wants to read, write, or search files via MCP protocol.
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
# Using MCP Filesystem Server
|
|
118
|
+
|
|
119
|
+
Access local files via the official MCP filesystem server.
|
|
120
|
+
|
|
121
|
+
## Quick Start
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npx tsx <skill-path>/scripts/filesystem.ts list-tools
|
|
125
|
+
npx tsx <skill-path>/scripts/filesystem.ts call read_file '{"path":"./README.md"}'
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Available Tools
|
|
129
|
+
|
|
130
|
+
- `read_file` - Read file contents
|
|
131
|
+
- `write_file` - Write content to file
|
|
132
|
+
- `list_directory` - List directory contents
|
|
133
|
+
- `search_files` - Search for files by pattern
|
|
134
|
+
- `get_file_info` - Get file metadata
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**scripts/filesystem.ts:**
|
|
138
|
+
Copy `converting-mcps-to-skills/scripts/mcp-stdio.ts` and set the default command to:
|
|
139
|
+
```typescript
|
|
140
|
+
const DEFAULT_COMMAND = "npx -y @modelcontextprotocol/server-filesystem .";
|
|
141
|
+
```
|