Skip to content

Commit 1cd825d

Browse files
authored
feat: add --project option to specify project for supermemory (#26)
- Add a new CLI option --project that only applies when installing a URL on https://api.supermemory.ai/*. - Behavior: - If --project is provided, it is validated (no spaces) and added as a header: x-sm-project: <value>. - If --project is omitted for Supermemory URLs, the installer prompts for a project. Empty input defaults to default (users can still override per LLM session). - The header is appended alongside any --header flags. - Works for both regular installs and Warp output (included in args as --header "x-sm-project: <value>"). - Does not affect non-URL installs or non-Supermemory URLs. Docs: - Update README with a new “Supermemory project support” section explaining: - When the flag applies - Validation rules - Prompting and default behavior - Examples and Warp notes
2 parents 75f1b48 + 1dbcfe4 commit 1cd825d

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,31 @@ The tool automatically:
3939
- Infers server names from package names or URLs (e.g., `mcp.example.com``mcp-example-com`)
4040
- Handles OAuth authentication for remote servers
4141

42+
### Supermemory project support
43+
44+
When installing a server hosted on `https://api.supermemory.ai/*`, you can pass a project name via `--project`. This is a convenience alias for adding the header `x-sm-project: <value>`.
45+
46+
Rules:
47+
48+
- Only applies to URL installs targeting `https://api.supermemory.ai/*`.
49+
- Values must not contain spaces.
50+
- If you omit `--project` for these URLs, you'll be prompted. Pressing Enter uses `default`.
51+
- The value is injected as a header alongside any `--header` flags.
52+
53+
Examples:
54+
55+
```bash
56+
# Explicit project
57+
npx install-mcp https://api.supermemory.ai/servers/my-server \
58+
--client cursor \
59+
--project myproj
60+
61+
# Prompted for project (Enter defaults to "default")
62+
npx install-mcp https://api.supermemory.ai/servers/my-server --client cursor
63+
```
64+
65+
Warp users: the generated config will include `--header "x-sm-project: <value>"` in the `args` array when installing Supermemory URLs.
66+
4267
### Headers Support
4368

4469
You can pass headers for authentication or other purposes using the `--header` flag:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "install-mcp",
3-
"version": "1.7.1",
3+
"version": "1.8.0",
44
"description": "A CLI tool to install and manage MCP servers.",
55
"bin": {
66
"install-mcp": "./bin/run"

src/commands/install.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export interface InstallArgv {
6464
yes?: boolean
6565
header?: string[]
6666
oauth?: 'yes' | 'no'
67+
project?: string
6768
}
6869

6970
export const command = '$0 [target]'
@@ -100,6 +101,7 @@ export function builder(yargs: Argv<InstallArgv>): Argv {
100101
description: 'Headers to pass to the server (format: "Header: value")',
101102
default: [],
102103
})
104+
.option('project', { type: 'string', description: 'Project for https://api.supermemory.ai/*' })
103105
.option('oauth', {
104106
type: 'string',
105107
description: 'Whether the server uses OAuth authentication (yes/no). If not specified, you will be prompted.',
@@ -154,6 +156,15 @@ function buildCommand(input: string): string {
154156
}
155157
}
156158

159+
function isSupermemoryUrl(input: string): boolean {
160+
try {
161+
const url = new URL(input)
162+
return url.hostname === 'api.supermemory.ai'
163+
} catch {
164+
return false
165+
}
166+
}
167+
157168
// Run the authentication flow for remote servers before installation.
158169
async function runAuthentication(url: string): Promise<void> {
159170
logger.info(`Running authentication for ${url}`)
@@ -190,6 +201,24 @@ export async function handler(argv: ArgumentsCamelCase<InstallArgv>) {
190201
const name = argv.name || inferNameFromInput(target)
191202
const command = buildCommand(target)
192203

204+
// Resolve Supermemory project header when installing its URL
205+
let projectHeader: string | undefined
206+
if (isUrl(target) && isSupermemoryUrl(target)) {
207+
let project = typeof argv.project === 'string' ? argv.project : undefined
208+
if (!project || project.trim() === '') {
209+
const input = (await logger.prompt(
210+
'Enter your Supermemory project (no spaces). Press Enter for "default" (you can override per LLM session).',
211+
{ type: 'text' },
212+
)) as string
213+
project = (input || '').trim() || 'default'
214+
}
215+
if (/\s/.test(project)) {
216+
logger.error('Project must not contain spaces. Use hyphens or underscores instead.')
217+
return
218+
}
219+
projectHeader = `x-sm-project:${project}`
220+
}
221+
193222
if (argv.client === 'warp') {
194223
logger.log('')
195224
logger.info('Warp requires a manual installation through their UI.')
@@ -205,6 +234,9 @@ export async function handler(argv: ArgumentsCamelCase<InstallArgv>) {
205234
warpArgs.push('--header', header)
206235
}
207236
}
237+
if (projectHeader) {
238+
warpArgs.push('--header', projectHeader)
239+
}
208240
} else {
209241
warpArgs = command.split(' ').slice(1)
210242
}
@@ -280,6 +312,9 @@ export async function handler(argv: ArgumentsCamelCase<InstallArgv>) {
280312
args.push('--header', header)
281313
}
282314
}
315+
if (projectHeader) {
316+
args.push('--header', projectHeader)
317+
}
283318
setServerConfig(
284319
config,
285320
configKey,

0 commit comments

Comments
 (0)