@foundation0/api 1.1.10 → 1.1.11
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.
- package/mcp/server.test.ts +40 -0
- package/mcp/server.ts +5 -0
- package/package.json +1 -1
package/mcp/server.test.ts
CHANGED
|
@@ -272,6 +272,46 @@ describe("createExampleMcpServer request handling", () => {
|
|
|
272
272
|
}
|
|
273
273
|
});
|
|
274
274
|
|
|
275
|
+
it("parses owner/repo repoName into repo segment even without full-name metadata", async () => {
|
|
276
|
+
const originalCwd = process.cwd();
|
|
277
|
+
const tempDir = await fs.mkdtemp(
|
|
278
|
+
path.join(os.tmpdir(), "f0-mcp-server-reponame-segment-fallback-"),
|
|
279
|
+
);
|
|
280
|
+
try {
|
|
281
|
+
await fs.mkdir(path.join(tempDir, "api"), { recursive: true });
|
|
282
|
+
await fs.mkdir(path.join(tempDir, "projects", "adl", "docs"), {
|
|
283
|
+
recursive: true,
|
|
284
|
+
});
|
|
285
|
+
await fs.mkdir(path.join(tempDir, ".git"), { recursive: true });
|
|
286
|
+
await fs.writeFile(path.join(tempDir, ".git", "config"), "", "utf8");
|
|
287
|
+
|
|
288
|
+
process.chdir(tempDir);
|
|
289
|
+
const instance = createExampleMcpServer();
|
|
290
|
+
const handler = getToolHandler(instance);
|
|
291
|
+
|
|
292
|
+
const result = await handler(
|
|
293
|
+
{
|
|
294
|
+
method: "tools/call",
|
|
295
|
+
params: {
|
|
296
|
+
name: "projects.listProjects",
|
|
297
|
+
arguments: {
|
|
298
|
+
repoName: "F0/adl",
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
{},
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
expect(result.isError).toBe(false);
|
|
306
|
+
const payload = JSON.parse(result.content?.[0]?.text ?? "{}");
|
|
307
|
+
expect(payload.ok).toBe(true);
|
|
308
|
+
expect(payload.result).toContain("adl");
|
|
309
|
+
} finally {
|
|
310
|
+
process.chdir(originalCwd);
|
|
311
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
|
|
275
315
|
it("auto-detects Git workspace from process.cwd() when repoName is omitted", async () => {
|
|
276
316
|
const tempDir = await fs.mkdtemp(
|
|
277
317
|
path.join(os.tmpdir(), "f0-mcp-server-autoworkspace-"),
|
package/mcp/server.ts
CHANGED
|
@@ -393,6 +393,11 @@ const resolveRepoSelectorOptions = (
|
|
|
393
393
|
next.repoName = matched;
|
|
394
394
|
return next;
|
|
395
395
|
}
|
|
396
|
+
if (repoSegment !== "." && repoSegment !== "..") {
|
|
397
|
+
next.processRoot = ctx.defaultProcessRoot;
|
|
398
|
+
next.repoName = repoSegment;
|
|
399
|
+
return next;
|
|
400
|
+
}
|
|
396
401
|
}
|
|
397
402
|
}
|
|
398
403
|
|