-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
34 lines (27 loc) · 970 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import dotenv from "dotenv";
import HackMDAPI from "@hackmd/api";
import { registerAllTools } from "./tools/index.js";
// Load environment variables
dotenv.config();
// Get API token from environment
const API_TOKEN = process.env.HACKMD_API_TOKEN;
if (!API_TOKEN) {
console.error("Error: HACKMD_API_TOKEN is required");
process.exit(1);
}
const API_URL = process.env.HACKMD_API_URL;
// Initialize HackMD API client
const client = new HackMDAPI.API(API_TOKEN, API_URL);
// Create an MCP server for HackMD API
const server = new McpServer({
name: "hackmd-mcp",
version: "1.2.4",
});
// Register all tools
registerAllTools(server, client);
// Start receiving messages on stdin and sending messages on stdout
const transport = new StdioServerTransport();
await server.connect(transport);