slite-mcp-server
Version:
'Slite MCP server'
62 lines (61 loc) • 1.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SliteClient = void 0;
class SliteClient {
apiKey;
baseUrl;
constructor({ apiKey, baseUrl }) {
this.apiKey = apiKey;
this.baseUrl = baseUrl;
}
async fetch(path) {
const response = await fetch(`${this.baseUrl}${path}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${this.apiKey}`,
'Content-Type': 'application/json',
},
});
const results = await response.json();
return results;
}
async search({ query }) {
try {
const results = await this.fetch(`/search-notes?query=${query}`);
return {
results,
};
}
catch (error) {
throw new Error(`Search failed: ${error.message}`);
}
}
async ask({ question }) {
try {
const response = await this.fetch(`/ask?question=${question}`);
return response;
}
catch (error) {
throw new Error(`Ask failed: ${error.message}`);
}
}
async getNote({ noteId }) {
try {
const response = await this.fetch(`/notes/${noteId}`);
return response;
}
catch (error) {
throw new Error(`Get note failed: ${error.message}`);
}
}
async getNoteChildren({ noteId }) {
try {
const response = await this.fetch(`/notes/${noteId}/children`);
return response;
}
catch (error) {
throw new Error(`Get note children failed: ${error.message}`);
}
}
}
exports.SliteClient = SliteClient;