@fre4x/arxiv 1.0.49 → 1.0.53
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/dist/index.js +120 -165
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -32491,6 +32491,14 @@ function applyPagination(items, params) {
|
|
|
32491
32491
|
};
|
|
32492
32492
|
}
|
|
32493
32493
|
|
|
32494
|
+
// ../packages/shared/dist/package.js
|
|
32495
|
+
import { createRequire as createJsonRequire } from "node:module";
|
|
32496
|
+
function getPackageVersion(moduleUrl) {
|
|
32497
|
+
const require2 = createJsonRequire(moduleUrl);
|
|
32498
|
+
const packageJson = require2("../package.json");
|
|
32499
|
+
return packageJson.version ?? "0.0.0";
|
|
32500
|
+
}
|
|
32501
|
+
|
|
32494
32502
|
// ../node_modules/zod/v3/helpers/util.js
|
|
32495
32503
|
var util;
|
|
32496
32504
|
(function(util4) {
|
|
@@ -47551,9 +47559,10 @@ var MOCK_FIXTURES = {
|
|
|
47551
47559
|
|
|
47552
47560
|
// src/index.ts
|
|
47553
47561
|
var api = new ArxivApiClient();
|
|
47562
|
+
var PACKAGE_VERSION = getPackageVersion(import.meta.url);
|
|
47554
47563
|
var server = new McpServer({
|
|
47555
47564
|
name: "arxiv-mcp-server",
|
|
47556
|
-
version:
|
|
47565
|
+
version: PACKAGE_VERSION
|
|
47557
47566
|
});
|
|
47558
47567
|
function formatPaperMarkdown(paper) {
|
|
47559
47568
|
const lines = [];
|
|
@@ -47583,13 +47592,12 @@ ${paper.summary}`);
|
|
|
47583
47592
|
}
|
|
47584
47593
|
function formatPaperListMarkdown(papers, total, start) {
|
|
47585
47594
|
const lines = [];
|
|
47586
|
-
lines.push(
|
|
47587
|
-
`);
|
|
47595
|
+
lines.push("# arXiv Search Results\n");
|
|
47588
47596
|
lines.push(
|
|
47589
47597
|
`Showing ${papers.length} of ${total} results (offset: ${start})
|
|
47590
47598
|
`
|
|
47591
47599
|
);
|
|
47592
|
-
papers.
|
|
47600
|
+
for (const [i, paper] of papers.entries()) {
|
|
47593
47601
|
lines.push(`### ${i + 1 + start}. ${paper.title}`);
|
|
47594
47602
|
lines.push(
|
|
47595
47603
|
`**arXiv**: [${paper.arxivId}](https://arxiv.org/abs/${paper.arxivId}) | **Authors**: ${paper.authors.slice(0, 3).map((a) => a.name).join(", ")}${paper.authors.length > 3 ? " et al." : ""}`
|
|
@@ -47601,7 +47609,7 @@ function formatPaperListMarkdown(papers, total, start) {
|
|
|
47601
47609
|
`> ${paper.summary.substring(0, 300)}${paper.summary.length > 300 ? "..." : ""}`
|
|
47602
47610
|
);
|
|
47603
47611
|
lines.push("");
|
|
47604
|
-
}
|
|
47612
|
+
}
|
|
47605
47613
|
if (total > start + papers.length) {
|
|
47606
47614
|
lines.push(
|
|
47607
47615
|
`*${total - start - papers.length} more results available. Use \`offset=${start + papers.length}\` to continue.*`
|
|
@@ -47616,6 +47624,82 @@ var sortSchema = {
|
|
|
47616
47624
|
var responseFormatSchema = {
|
|
47617
47625
|
response_format: external_exports.enum(Object.values(ResponseFormat)).default("markdown" /* MARKDOWN */).describe("Output format: markdown or json")
|
|
47618
47626
|
};
|
|
47627
|
+
async function handleArxivSearch(params) {
|
|
47628
|
+
try {
|
|
47629
|
+
const result = IS_MOCK || process.env.MOCK === "true" ? MOCK_FIXTURES.search : await api.search({
|
|
47630
|
+
query: params.query,
|
|
47631
|
+
start: params.offset,
|
|
47632
|
+
maxResults: params.limit,
|
|
47633
|
+
sortBy: params.sort_by,
|
|
47634
|
+
sortOrder: params.sort_order
|
|
47635
|
+
});
|
|
47636
|
+
if (params.response_format === "json" /* JSON */) {
|
|
47637
|
+
return {
|
|
47638
|
+
content: [
|
|
47639
|
+
{
|
|
47640
|
+
type: "text",
|
|
47641
|
+
text: truncateToLimit(JSON.stringify(result, null, 2))
|
|
47642
|
+
}
|
|
47643
|
+
],
|
|
47644
|
+
structuredContent: result
|
|
47645
|
+
};
|
|
47646
|
+
}
|
|
47647
|
+
return {
|
|
47648
|
+
content: [
|
|
47649
|
+
{
|
|
47650
|
+
type: "text",
|
|
47651
|
+
text: truncateToLimit(
|
|
47652
|
+
formatPaperListMarkdown(
|
|
47653
|
+
result.papers,
|
|
47654
|
+
result.totalResults,
|
|
47655
|
+
result.startIndex
|
|
47656
|
+
)
|
|
47657
|
+
)
|
|
47658
|
+
}
|
|
47659
|
+
]
|
|
47660
|
+
};
|
|
47661
|
+
} catch (err) {
|
|
47662
|
+
return createInternalError(err);
|
|
47663
|
+
}
|
|
47664
|
+
}
|
|
47665
|
+
async function handleArxivGetPaper(params) {
|
|
47666
|
+
try {
|
|
47667
|
+
const result = IS_MOCK || process.env.MOCK === "true" ? MOCK_FIXTURES.getById : await api.getById(params.ids);
|
|
47668
|
+
if (result.papers.length === 0) {
|
|
47669
|
+
return {
|
|
47670
|
+
content: [
|
|
47671
|
+
{
|
|
47672
|
+
type: "text",
|
|
47673
|
+
text: "No papers found for the given IDs."
|
|
47674
|
+
}
|
|
47675
|
+
]
|
|
47676
|
+
};
|
|
47677
|
+
}
|
|
47678
|
+
if (params.response_format === "json" /* JSON */) {
|
|
47679
|
+
return {
|
|
47680
|
+
content: [
|
|
47681
|
+
{
|
|
47682
|
+
type: "text",
|
|
47683
|
+
text: truncateToLimit(
|
|
47684
|
+
JSON.stringify(result.papers, null, 2)
|
|
47685
|
+
)
|
|
47686
|
+
}
|
|
47687
|
+
],
|
|
47688
|
+
structuredContent: {
|
|
47689
|
+
papers: result.papers
|
|
47690
|
+
}
|
|
47691
|
+
};
|
|
47692
|
+
}
|
|
47693
|
+
const markdown = result.papers.map((p) => formatPaperMarkdown(p)).join("\n\n---\n\n");
|
|
47694
|
+
return {
|
|
47695
|
+
content: [
|
|
47696
|
+
{ type: "text", text: truncateToLimit(markdown) }
|
|
47697
|
+
]
|
|
47698
|
+
};
|
|
47699
|
+
} catch (err) {
|
|
47700
|
+
return createInternalError(err);
|
|
47701
|
+
}
|
|
47702
|
+
}
|
|
47619
47703
|
server.registerTool(
|
|
47620
47704
|
"arxiv_search_papers",
|
|
47621
47705
|
{
|
|
@@ -47633,46 +47717,8 @@ server.registerTool(
|
|
|
47633
47717
|
openWorldHint: true
|
|
47634
47718
|
}
|
|
47635
47719
|
},
|
|
47636
|
-
|
|
47637
|
-
|
|
47638
|
-
const result = IS_MOCK ? MOCK_FIXTURES.search : await api.search({
|
|
47639
|
-
query: params.query,
|
|
47640
|
-
start: params.offset,
|
|
47641
|
-
maxResults: params.limit,
|
|
47642
|
-
sortBy: params.sort_by,
|
|
47643
|
-
sortOrder: params.sort_order
|
|
47644
|
-
});
|
|
47645
|
-
if (params.response_format === "json" /* JSON */) {
|
|
47646
|
-
return {
|
|
47647
|
-
content: [
|
|
47648
|
-
{
|
|
47649
|
-
type: "text",
|
|
47650
|
-
text: truncateToLimit(
|
|
47651
|
-
JSON.stringify(result, null, 2)
|
|
47652
|
-
)
|
|
47653
|
-
}
|
|
47654
|
-
],
|
|
47655
|
-
structuredContent: result
|
|
47656
|
-
};
|
|
47657
|
-
}
|
|
47658
|
-
return {
|
|
47659
|
-
content: [
|
|
47660
|
-
{
|
|
47661
|
-
type: "text",
|
|
47662
|
-
text: truncateToLimit(
|
|
47663
|
-
formatPaperListMarkdown(
|
|
47664
|
-
result.papers,
|
|
47665
|
-
result.totalResults,
|
|
47666
|
-
result.startIndex
|
|
47667
|
-
)
|
|
47668
|
-
)
|
|
47669
|
-
}
|
|
47670
|
-
]
|
|
47671
|
-
};
|
|
47672
|
-
} catch (err) {
|
|
47673
|
-
return createInternalError(err);
|
|
47674
|
-
}
|
|
47675
|
-
}
|
|
47720
|
+
// @ts-expect-error - Schema inference can be tricky with split handlers
|
|
47721
|
+
handleArxivSearch
|
|
47676
47722
|
);
|
|
47677
47723
|
server.registerTool(
|
|
47678
47724
|
"arxiv_get_paper",
|
|
@@ -47689,44 +47735,8 @@ server.registerTool(
|
|
|
47689
47735
|
openWorldHint: true
|
|
47690
47736
|
}
|
|
47691
47737
|
},
|
|
47692
|
-
|
|
47693
|
-
|
|
47694
|
-
const result = IS_MOCK ? MOCK_FIXTURES.getById : await api.getById(params.ids);
|
|
47695
|
-
if (result.papers.length === 0) {
|
|
47696
|
-
return {
|
|
47697
|
-
content: [
|
|
47698
|
-
{
|
|
47699
|
-
type: "text",
|
|
47700
|
-
text: "No papers found for the given IDs."
|
|
47701
|
-
}
|
|
47702
|
-
]
|
|
47703
|
-
};
|
|
47704
|
-
}
|
|
47705
|
-
if (params.response_format === "json" /* JSON */) {
|
|
47706
|
-
return {
|
|
47707
|
-
content: [
|
|
47708
|
-
{
|
|
47709
|
-
type: "text",
|
|
47710
|
-
text: truncateToLimit(
|
|
47711
|
-
JSON.stringify(result.papers, null, 2)
|
|
47712
|
-
)
|
|
47713
|
-
}
|
|
47714
|
-
],
|
|
47715
|
-
structuredContent: {
|
|
47716
|
-
papers: result.papers
|
|
47717
|
-
}
|
|
47718
|
-
};
|
|
47719
|
-
}
|
|
47720
|
-
const markdown = result.papers.map((p) => formatPaperMarkdown(p)).join("\n\n---\n\n");
|
|
47721
|
-
return {
|
|
47722
|
-
content: [
|
|
47723
|
-
{ type: "text", text: truncateToLimit(markdown) }
|
|
47724
|
-
]
|
|
47725
|
-
};
|
|
47726
|
-
} catch (err) {
|
|
47727
|
-
return createInternalError(err);
|
|
47728
|
-
}
|
|
47729
|
-
}
|
|
47738
|
+
// @ts-expect-error
|
|
47739
|
+
handleArxivGetPaper
|
|
47730
47740
|
);
|
|
47731
47741
|
server.registerTool(
|
|
47732
47742
|
"arxiv_search_by_author",
|
|
@@ -47746,44 +47756,13 @@ server.registerTool(
|
|
|
47746
47756
|
}
|
|
47747
47757
|
},
|
|
47748
47758
|
async (params) => {
|
|
47749
|
-
|
|
47750
|
-
|
|
47751
|
-
|
|
47752
|
-
|
|
47753
|
-
|
|
47754
|
-
|
|
47755
|
-
|
|
47756
|
-
});
|
|
47757
|
-
if (params.response_format === "json" /* JSON */) {
|
|
47758
|
-
return {
|
|
47759
|
-
content: [
|
|
47760
|
-
{
|
|
47761
|
-
type: "text",
|
|
47762
|
-
text: truncateToLimit(
|
|
47763
|
-
JSON.stringify(result, null, 2)
|
|
47764
|
-
)
|
|
47765
|
-
}
|
|
47766
|
-
],
|
|
47767
|
-
structuredContent: result
|
|
47768
|
-
};
|
|
47769
|
-
}
|
|
47770
|
-
return {
|
|
47771
|
-
content: [
|
|
47772
|
-
{
|
|
47773
|
-
type: "text",
|
|
47774
|
-
text: truncateToLimit(
|
|
47775
|
-
formatPaperListMarkdown(
|
|
47776
|
-
result.papers,
|
|
47777
|
-
result.totalResults,
|
|
47778
|
-
result.startIndex
|
|
47779
|
-
)
|
|
47780
|
-
)
|
|
47781
|
-
}
|
|
47782
|
-
]
|
|
47783
|
-
};
|
|
47784
|
-
} catch (err) {
|
|
47785
|
-
return createInternalError(err);
|
|
47786
|
-
}
|
|
47759
|
+
return handleArxivSearch({
|
|
47760
|
+
...params,
|
|
47761
|
+
query: `au:${params.author}`,
|
|
47762
|
+
sort_by: params.sort_by,
|
|
47763
|
+
sort_order: params.sort_order,
|
|
47764
|
+
response_format: params.response_format
|
|
47765
|
+
});
|
|
47787
47766
|
}
|
|
47788
47767
|
);
|
|
47789
47768
|
server.registerTool(
|
|
@@ -47808,46 +47787,15 @@ server.registerTool(
|
|
|
47808
47787
|
}
|
|
47809
47788
|
},
|
|
47810
47789
|
async (params) => {
|
|
47811
|
-
|
|
47812
|
-
|
|
47813
|
-
|
|
47814
|
-
|
|
47815
|
-
|
|
47816
|
-
|
|
47817
|
-
|
|
47818
|
-
|
|
47819
|
-
|
|
47820
|
-
});
|
|
47821
|
-
if (params.response_format === "json" /* JSON */) {
|
|
47822
|
-
return {
|
|
47823
|
-
content: [
|
|
47824
|
-
{
|
|
47825
|
-
type: "text",
|
|
47826
|
-
text: truncateToLimit(
|
|
47827
|
-
JSON.stringify(result, null, 2)
|
|
47828
|
-
)
|
|
47829
|
-
}
|
|
47830
|
-
],
|
|
47831
|
-
structuredContent: result
|
|
47832
|
-
};
|
|
47833
|
-
}
|
|
47834
|
-
return {
|
|
47835
|
-
content: [
|
|
47836
|
-
{
|
|
47837
|
-
type: "text",
|
|
47838
|
-
text: truncateToLimit(
|
|
47839
|
-
formatPaperListMarkdown(
|
|
47840
|
-
result.papers,
|
|
47841
|
-
result.totalResults,
|
|
47842
|
-
result.startIndex
|
|
47843
|
-
)
|
|
47844
|
-
)
|
|
47845
|
-
}
|
|
47846
|
-
]
|
|
47847
|
-
};
|
|
47848
|
-
} catch (err) {
|
|
47849
|
-
return createInternalError(err);
|
|
47850
|
-
}
|
|
47790
|
+
const queryParts = [`cat:${params.category}`];
|
|
47791
|
+
if (params.query) queryParts.push(`AND all:${params.query}`);
|
|
47792
|
+
return handleArxivSearch({
|
|
47793
|
+
...params,
|
|
47794
|
+
query: queryParts.join(" "),
|
|
47795
|
+
sort_by: params.sort_by,
|
|
47796
|
+
sort_order: params.sort_order,
|
|
47797
|
+
response_format: params.response_format
|
|
47798
|
+
});
|
|
47851
47799
|
}
|
|
47852
47800
|
);
|
|
47853
47801
|
server.registerTool(
|
|
@@ -47898,10 +47846,17 @@ async function main() {
|
|
|
47898
47846
|
await server.connect(transport);
|
|
47899
47847
|
console.error("arXiv MCP server running on stdio");
|
|
47900
47848
|
}
|
|
47901
|
-
|
|
47902
|
-
|
|
47903
|
-
|
|
47904
|
-
|
|
47849
|
+
if (process.env.NODE_ENV !== "test") {
|
|
47850
|
+
main().catch((err) => {
|
|
47851
|
+
console.error("Fatal error:", err);
|
|
47852
|
+
process.exit(1);
|
|
47853
|
+
});
|
|
47854
|
+
}
|
|
47855
|
+
export {
|
|
47856
|
+
handleArxivGetPaper,
|
|
47857
|
+
handleArxivSearch,
|
|
47858
|
+
server
|
|
47859
|
+
};
|
|
47905
47860
|
/*! Bundled license information:
|
|
47906
47861
|
|
|
47907
47862
|
mime-db/index.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fre4x/arxiv",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.53",
|
|
4
4
|
"description": "An arXiv MCP server for searching and retrieving academic papers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
|
-
"build": "node
|
|
14
|
+
"build": "node ../scripts/build-package.mjs",
|
|
15
15
|
"typecheck": "cross-env NODE_OPTIONS=--max-old-space-size=4096 tsc --noEmit",
|
|
16
16
|
"start": "node dist/index.js",
|
|
17
17
|
"dev": "tsx src/index.ts",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"author": "fritzprix",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
33
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
34
34
|
"axios": "^1.13.5",
|
|
35
35
|
"fast-xml-parser": "^5.4.1",
|
|
36
|
-
"zod": "^4.
|
|
36
|
+
"zod": "^4.3.6"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^25.3.
|
|
39
|
+
"@types/node": "^25.3.5",
|
|
40
40
|
"tsx": "^4.21.0",
|
|
41
41
|
"typescript": "^5.9.3",
|
|
42
42
|
"vitest": "^4.0.18"
|