Skip to content

Commit ea66d2a

Browse files
committed
👌 IMPROVE: Review by SI
1 parent a0addd6 commit ea66d2a

File tree

6 files changed

+699
-177
lines changed

6 files changed

+699
-177
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ To test the changes locally, you can run the following command:
3232

3333
```json
3434
{
35-
"dependencies": {
36-
"langbase": "workspace:*"
37-
},
35+
"dependencies": {
36+
"langbase": "workspace:*"
37+
}
3838
}
3939
```
4040

packages/cli/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,3 @@ Integrate the Langbase Docs MCP server into Cursor IDE.
3030
}
3131
}
3232
```
33-
34-
35-

packages/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"devDependencies": {
9393
"@langbase/eslint-config": "workspace:*",
9494
"@langbase/tsconfig": "workspace:*",
95+
"@types/jsdom": "^21.1.7",
9596
"@types/node": "^22.6.1",
9697
"tsup": "^8.3.0",
9798
"tsx": "^4.19.1",

packages/cli/src/docs-mcp-server/docs.ts

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,57 @@ import { JSDOM } from 'jsdom';
22

33
/**
44
* Fetches a list of all the docs on the langbase website
5+
*
6+
*
57
* @returns {Promise<string>} A promise that resolves to a string of all the docs on the langbase website
68
*/
7-
89
export async function fetchDocsList() {
910
try {
10-
const response = await fetch('https://langbase.com/docs/llms.txt');
11-
12-
if (!response.ok) {
13-
throw new Error('Failed to fetch docs');
14-
}
15-
16-
const text = await response.text();
17-
return text;
18-
19-
} catch (error) {
20-
throw new Error('Failed to fetch docs ' + JSON.stringify(error));
21-
}
11+
const response = await fetch('https://langbase.com/docs/llms.txt');
12+
if (!response.ok) {
13+
throw new Error('Failed to fetch docs');
14+
}
15+
16+
const text = await response.text();
17+
return text;
18+
} catch (error) {
19+
throw new Error('Failed to fetch docs ' + JSON.stringify(error));
20+
}
2221
}
2322

2423
/**
2524
* Fetches and converts a blog post to markdown
25+
*
26+
*
2627
* @param {string} url - The URL of the blog post to fetch
2728
* @returns {Promise<string>} A promise that resolves to a string of the blog post in markdown format
2829
*/
29-
3030
export async function fetchDocsPost(url: string): Promise<string> {
3131
try {
32-
const response = await fetch(url);
33-
if (!response.ok) {
34-
throw new Error('Failed to fetch blog post');
35-
}
36-
37-
const html = await response.text();
38-
32+
const response = await fetch(url);
33+
if (!response.ok) {
34+
throw new Error('Failed to fetch blog post');
35+
}
36+
37+
const html = await response.text();
38+
3939
const dom = new JSDOM(html);
4040
const document = dom.window.document;
41+
4142
// Remove Next.js initialization code
4243
const scripts = document.querySelectorAll('script');
4344
scripts.forEach(script => script.remove());
44-
45+
4546
// Get the main content
4647
const content = document.body.textContent?.trim() || '';
4748
if (!content) {
4849
throw new Error('No content found in docs');
4950
}
50-
51-
return content;
5251

53-
} catch (error) {
54-
throw new Error(`Failed to fetch docs: ${error instanceof Error ? error.message : 'Unknown error'}`);
55-
}
56-
}
52+
return content;
53+
} catch (error) {
54+
throw new Error(
55+
`Failed to fetch docs: ${error instanceof Error ? error.message : 'Something went wrong. Please try again.'}`
56+
);
57+
}
58+
}

0 commit comments

Comments
 (0)