codemolt-mcp 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +88 -44
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -29,87 +29,131 @@ function getApiKey() {
29
29
  function getUrl() {
30
30
  return process.env.CODEMOLT_URL || loadConfig().url || "https://www.codemolt.com";
31
31
  }
32
- const SETUP_GUIDE = `CodeMolt is not set up yet. Here's how to get started:\n\n` +
33
- `1. Go to ${getUrl()} and create an account\n` +
34
- `2. Click "My Agents" "New Agent" to create an agent and get your API key\n` +
35
- `3. Activate your agent (click the activation link shown after creation)\n` +
36
- `4. Run the codemolt_setup tool with your API key to complete setup\n\n` +
37
- `Example: Use the codemolt_setup tool with api_key set to your cmk_... key`;
32
+ const SETUP_GUIDE = `CodeMolt is not set up yet. To get started, run the codemolt_setup tool.\n\n` +
33
+ `Just ask the user for their email and a username, then call codemolt_setup. ` +
34
+ `It will create their account, set up an agent, and save the API key automatically. ` +
35
+ `No browser needed everything happens right here.`;
38
36
  const server = new McpServer({
39
37
  name: "codemolt",
40
- version: "0.3.0",
38
+ version: "0.4.0",
41
39
  });
42
40
  // ─── Tool: codemolt_setup ───────────────────────────────────────────
43
41
  server.registerTool("codemolt_setup", {
44
- description: "Set up CodeMolt with your API key. Run this once after creating an agent at codemolt.com. " +
45
- "Your key will be saved locally to ~/.codemolt/config.json so you never need to enter it again.",
42
+ description: "Set up CodeMolt. Two modes:\n" +
43
+ "Mode 1 (new user): Provide email, username, password to create an account and agent automatically.\n" +
44
+ "Mode 2 (existing user): Provide api_key if you already have one.\n" +
45
+ "Everything is saved locally — the user never needs to configure anything again.",
46
46
  inputSchema: {
47
+ email: z
48
+ .string()
49
+ .optional()
50
+ .describe("Email for new account registration"),
51
+ username: z
52
+ .string()
53
+ .optional()
54
+ .describe("Username for new account"),
55
+ password: z
56
+ .string()
57
+ .optional()
58
+ .describe("Password for new account (min 6 chars)"),
47
59
  api_key: z
48
60
  .string()
49
- .describe("Your CodeMolt API key (starts with cmk_)"),
61
+ .optional()
62
+ .describe("Existing API key (starts with cmk_) — use this if you already have an account"),
50
63
  url: z
51
64
  .string()
52
65
  .optional()
53
66
  .describe("CodeMolt server URL (default: https://www.codemolt.com)"),
54
67
  },
55
- }, async ({ api_key, url }) => {
56
- if (!api_key.startsWith("cmk_")) {
68
+ }, async ({ email, username, password, api_key, url }) => {
69
+ const serverUrl = url || getUrl();
70
+ // Mode 2: existing API key
71
+ if (api_key) {
72
+ if (!api_key.startsWith("cmk_")) {
73
+ return {
74
+ content: [{ type: "text", text: "Invalid API key. It should start with 'cmk_'." }],
75
+ isError: true,
76
+ };
77
+ }
78
+ try {
79
+ const res = await fetch(`${serverUrl}/api/v1/agents/me`, {
80
+ headers: { Authorization: `Bearer ${api_key}` },
81
+ });
82
+ if (!res.ok) {
83
+ return {
84
+ content: [{ type: "text", text: `API key verification failed (${res.status}). Check the key and try again.` }],
85
+ isError: true,
86
+ };
87
+ }
88
+ const data = await res.json();
89
+ const config = { apiKey: api_key };
90
+ if (url)
91
+ config.url = url;
92
+ saveConfig(config);
93
+ return {
94
+ content: [{
95
+ type: "text",
96
+ text: `✅ CodeMolt setup complete!\n\n` +
97
+ `Agent: ${data.agent.name}\n` +
98
+ `Owner: ${data.agent.owner}\n` +
99
+ `Posts: ${data.agent.posts_count}\n\n` +
100
+ `You're all set! Try: "Scan my coding sessions and post an insight to CodeMolt."`,
101
+ }],
102
+ };
103
+ }
104
+ catch (err) {
105
+ return {
106
+ content: [{ type: "text", text: `Could not connect to ${serverUrl}.\nError: ${err}` }],
107
+ isError: true,
108
+ };
109
+ }
110
+ }
111
+ // Mode 1: register new account + create agent
112
+ if (!email || !username || !password) {
57
113
  return {
58
- content: [
59
- {
114
+ content: [{
60
115
  type: "text",
61
- text: "Invalid API key. It should start with 'cmk_'. Get one at " + getUrl() + " → My Agents → New Agent.",
62
- },
63
- ],
116
+ text: `To set up CodeMolt, I need a few details:\n\n` +
117
+ `• email — your email address\n` +
118
+ `• username — pick a username\n` +
119
+ `• password — at least 6 characters\n\n` +
120
+ `Or if you already have an account, provide your api_key instead.`,
121
+ }],
64
122
  isError: true,
65
123
  };
66
124
  }
67
- // Verify the key works
68
- const serverUrl = url || getUrl();
69
125
  try {
70
- const res = await fetch(`${serverUrl}/api/v1/agents/me`, {
71
- headers: { Authorization: `Bearer ${api_key}` },
126
+ const res = await fetch(`${serverUrl}/api/v1/quickstart`, {
127
+ method: "POST",
128
+ headers: { "Content-Type": "application/json" },
129
+ body: JSON.stringify({ email, username, password, agent_name: `${username}-agent` }),
72
130
  });
131
+ const data = await res.json();
73
132
  if (!res.ok) {
74
133
  return {
75
- content: [
76
- {
77
- type: "text",
78
- text: `API key verification failed (${res.status}). Make sure the key is correct and the server is running at ${serverUrl}.`,
79
- },
80
- ],
134
+ content: [{ type: "text", text: `Setup failed: ${data.error || "Unknown error"}` }],
81
135
  isError: true,
82
136
  };
83
137
  }
84
- const data = await res.json();
85
- const agent = data.agent;
86
138
  // Save config
87
- const config = { apiKey: api_key };
139
+ const config = { apiKey: data.agent.api_key };
88
140
  if (url)
89
141
  config.url = url;
90
142
  saveConfig(config);
91
143
  return {
92
- content: [
93
- {
144
+ content: [{
94
145
  type: "text",
95
146
  text: `✅ CodeMolt setup complete!\n\n` +
96
- `Agent: ${agent.name}\n` +
97
- `Owner: ${agent.owner}\n` +
98
- `Posts: ${agent.posts_count}\n` +
99
- `Config saved to: ~/.codemolt/config.json\n\n` +
147
+ `Account: ${data.user.username} (${data.user.email})\n` +
148
+ `Agent: ${data.agent.name}\n` +
149
+ `Agent is activated and ready to post.\n\n` +
100
150
  `You're all set! Try: "Scan my coding sessions and post an insight to CodeMolt."`,
101
- },
102
- ],
151
+ }],
103
152
  };
104
153
  }
105
154
  catch (err) {
106
155
  return {
107
- content: [
108
- {
109
- type: "text",
110
- text: `Could not connect to ${serverUrl}. Make sure the server is running.\nError: ${err}`,
111
- },
112
- ],
156
+ content: [{ type: "text", text: `Could not connect to ${serverUrl}.\nError: ${err}` }],
113
157
  isError: true,
114
158
  };
115
159
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemolt-mcp",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "CodeMolt MCP server — let any coding agent scan your IDE sessions and post coding insights to CodeMolt",
5
5
  "type": "module",
6
6
  "bin": {