Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 106 additions & 18 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,142 @@ The Langbase CLI is a command-line interface for Langbase. It provides a set of
Integrate the Langbase Docs MCP server into your IDEs and Claude Desktop.

#### Cursor

- Open Cursor settings
- Navigate to the MCP settings
- Click on the `+` button to add a new global MCP server
- Paste the following configuration in the `mcp.json` file:

```json
{
"mcpServers": {
"Langbase": {
"command": "npx",
"args": ["@langbase/cli","docs-mcp-server"]
}
}
"mcpServers": {
"Langbase": {
"command": "npx",
"args": ["@langbase/cli", "docs-mcp-server"]
}
}
}
```

#### Windsurf

- Navigate to Windsurf - Settings > Advanced Settings
- You will find the option to Add Server
- Click “Add custom server +”
- Paste the following configuration in the `mcp_config.json` file:

```json
{
"mcpServers": {
"Langbase": {
"command": "npx",
"args": ["@langbase/cli", "docs-mcp-server"]
}
}
"mcpServers": {
"Langbase": {
"command": "npx",
"args": ["@langbase/cli", "docs-mcp-server"]
}
}
}
```

#### Claude Desktop

- Open Claude Desktop File Menu
- Navigate to the settings
- Go to Developer Tab
- Click on the Edit Config button
- Paste the following configuration in the `claude_desktop_config.json` file:

```json
{
"mcpServers": {
"Langbase": {
"command": "npx",
"args": ["@langbase/cli", "docs-mcp-server"]
}
}
"mcpServers": {
"Langbase": {
"command": "npx",
"args": ["@langbase/cli", "docs-mcp-server"]
}
}
}
```

## CLI Commands

Get started with the Langbase CLI by running the following command:

```bash
npx @langbase/cli help
```

### Pipe Agent

The CLI provides commands to manage your Langbase pipes.

- Create a new pipe agent

```bash
npx @langbase/cli pipe
```

- Run a pipe agent

```bash
npx @langbase/cli pipe --run
```

- List all pipe agents

```bash
npx @langbase/cli pipe --listPipes
```

- Update a pipe agent

```bash
npx @langbase/cli pipe --update
```

### Memory

The CLI provides commands to manage your Langbase memories.

- Create a new memory

```bash
npx @langbase/cli memory
```

- Upload a document to memory

```bash
npx @langbase/cli memory --upload
```

- List all memories

```bash
npx @langbase/cli memory --listMemories
```

- Retrieve chunks from memory

```bash
npx @langbase/cli memory --retrieve
```

- List all documents in memory

```bash
npx @langbase/cli memory --listDocs
```

- Retry embedding of a document in a memory

```bash
npx @langbase/cli memory --embed
```

- Delete a memory

```bash
npx @langbase/cli memory --delete
```

## Next steps

- Read the [Langbase SDK documentation](https://langbase.com/docs/sdk) for more details
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@clack/prompts": "^0.7.0",
"@hono/node-server": "^1.13.1",
"@hono/zod-openapi": "^0.16.0",
"@langbase/cli": "^0.1.4",
"@modelcontextprotocol/sdk": "^1.8.0",
"@sindresorhus/slugify": "^2.2.1",
"camelcase": "^8.0.0",
Expand All @@ -73,6 +74,7 @@
"hono": "^4.5.11",
"js-tiktoken": "^1.0.14",
"jsdom": "^24.1.0",
"langbase": "^1.1.55",
"log-symbols": "^7.0.0",
"lowdb": "^7.0.1",
"meow": "^13.2.0",
Expand All @@ -87,7 +89,8 @@
"uuid": "^10.0.0",
"xlsx": "^0.18.5",
"zod": "^3.23.8",
"zod-error": "^1.5.0"
"zod-error": "^1.5.0",
"zod-validation-error": "^3.3.0"
},
"devDependencies": {
"@langbase/eslint-config": "workspace:*",
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,4 @@ export async function auth() {
`Authentication successful. API key is stored in ${envFile}`
)
);
process.exit(0);
}
69 changes: 68 additions & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ import { auth } from './auth';
import { build } from './build';
import { deploy } from './deploy';
import { docsMcpServer } from './docs-mcp-server';
import { createPipe } from './pipe/create';
import { runPipe } from './pipe/run';
import { updatePipe } from './pipe/update';
import { listPipes } from './pipe/list';
import cli from './utils/cli';
import debugMode from './utils/debug-mode';
import cliInit from './utils/init';

import { createMemory } from './memory/create';
import { listMemories } from './memory/list';
import { deleteMemory } from './memory/delete';
import { uploadDocs } from './memory/upload-docs';
import { embedDoc } from './memory/embed-doc';
import { retriveFromMemory } from './memory/retrive';
import { listDocs } from './memory/list-docs';
const { flags, input, showHelp } = cli;
const { clear, debug } = flags;

Expand Down Expand Up @@ -50,4 +60,61 @@ const flag = (flg: string): boolean => Boolean(flags[flg]);
if (command('docs-mcp-server')) {
await docsMcpServer();
}

if (
command('pipe') &&
!flag('run') &&
!flag('update') &&
!flag('listPipes')
) {
await createPipe();
}

if (command('pipe') && flag('run')) {
await runPipe();
}

if (command('pipe') && flag('update')) {
await updatePipe();
}

if (command('pipe') && flag('listPipes')) {
await listPipes();
}

if (
command('memory') &&
!flag('upload') &&
!flag('embed') &&
!flag('retrieve') &&
!flag('listDocs') &&
!flag('delete') &&
!flag('listMemories')
) {
await createMemory();
}

if (command('memory') && flag('listMemories')) {
await listMemories();
}

if (command('memory') && flag('delete')) {
await deleteMemory();
}

if (command('memory') && flag('upload')) {
await uploadDocs();
}

if (command('memory') && flag('embed')) {
await embedDoc();
}

if (command('memory') && flag('retrieve')) {
await retriveFromMemory();
}

if (command('memory') && flag('listDocs')) {
await listDocs();
}
})();
Loading
Loading