mcp-rule34 1.1.0 → 2.0.1

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 CHANGED
@@ -1,10 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
+ import process2 from "process";
4
5
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
6
 
7
+ // src/config.ts
8
+ import process from "process";
9
+
6
10
  // src/version.ts
7
- var PKG_VERSION = "1.1.0";
11
+ var PKG_VERSION = "2.0.1";
8
12
  var REPO_URL = "https://github.com/smeet666/mcp-rule34";
9
13
 
10
14
  // src/config.ts
@@ -590,6 +594,8 @@ function asTransportError(error, safeUrl) {
590
594
  }
591
595
 
592
596
  // src/rule34/parsers/postDetail.ts
597
+ var AUTHENTICATION = /authenticat/i;
598
+ var WHITESPACE = /\s+/;
593
599
  var TYPES = {
594
600
  tag: "general",
595
601
  artist: "artist",
@@ -609,7 +615,7 @@ function parsePostDetail(body, url, id) {
609
615
  throw parseFailure(safeUrl, "the response is not JSON", error);
610
616
  }
611
617
  if (typeof parsed === "string") {
612
- if (/authenticat/i.test(parsed)) {
618
+ if (AUTHENTICATION.test(parsed)) {
613
619
  throw missingCredentials(safeUrl);
614
620
  }
615
621
  throw upstreamFailure(safeUrl, parsed);
@@ -628,7 +634,7 @@ function parsePostDetail(body, url, id) {
628
634
  }
629
635
  function readPost(raw, askedFor) {
630
636
  const id = readInteger(raw.id) ?? askedFor;
631
- const tags = readString(raw.tags).split(/\s+/).filter((tag) => tag !== "");
637
+ const tags = readString(raw.tags).split(WHITESPACE).filter((tag) => tag !== "");
632
638
  return {
633
639
  id,
634
640
  postUrl: buildPostPageUrl(id),
@@ -728,6 +734,7 @@ function parseTagSuggestions(body, url) {
728
734
 
729
735
  // src/rule34/parsers/document.ts
730
736
  import { XMLParser } from "fast-xml-parser";
737
+ var AUTHENTICATION2 = /authenticat/i;
731
738
  var parser = new XMLParser({
732
739
  ignoreAttributes: false,
733
740
  attributeNamePrefix: "@_",
@@ -753,7 +760,7 @@ function readDocument(xml, safeUrl) {
753
760
  const failure = parsed.error;
754
761
  if (failure !== void 0) {
755
762
  const message = typeof failure === "string" ? failure : String(failure);
756
- if (/authenticat/i.test(message)) {
763
+ if (AUTHENTICATION2.test(message)) {
757
764
  throw missingCredentials(safeUrl);
758
765
  }
759
766
  throw upstreamFailure(safeUrl, message);
@@ -780,6 +787,7 @@ function readInteger2(value) {
780
787
  }
781
788
 
782
789
  // src/rule34/parsers/posts.ts
790
+ var WHITESPACE2 = /\s+/;
783
791
  var RATINGS = {
784
792
  e: "explicit",
785
793
  q: "questionable",
@@ -819,7 +827,7 @@ function readPost2(attributes) {
819
827
  // An unknown letter is carried as it came: naming it would state a rating
820
828
  // the site never wrote.
821
829
  rating: RATINGS[rating] ?? rating,
822
- tags: (attributes["@_tags"] ?? "").split(/\s+/).filter((tag) => tag !== ""),
830
+ tags: (attributes["@_tags"] ?? "").split(WHITESPACE2).filter((tag) => tag !== ""),
823
831
  source: readText2(attributes["@_source"]),
824
832
  // The attribute is present and empty on a post with no parent, and 0 is a
825
833
  // post id that belongs to somebody else.
@@ -991,7 +999,7 @@ var Rule34Client = class {
991
999
  config: this.deps.config,
992
1000
  limiter: this.limiter,
993
1001
  logger: this.deps.logger,
994
- fetchImpl: this.deps.fetchImpl
1002
+ ...this.deps.fetchImpl ? { fetchImpl: this.deps.fetchImpl } : {}
995
1003
  });
996
1004
  this.cache.set(key, body);
997
1005
  return { body, cached: false };
@@ -1392,10 +1400,10 @@ var searchPostsOutputShape = {
1392
1400
  function toSearch(args) {
1393
1401
  return {
1394
1402
  tags: args.tags,
1395
- anyOf: args.any_of,
1396
- exclude: args.exclude,
1403
+ ...args.any_of ? { anyOf: args.any_of } : {},
1404
+ ...args.exclude ? { exclude: args.exclude } : {},
1397
1405
  mediaType: args.media_type,
1398
- rating: args.rating,
1406
+ ...args.rating ? { rating: args.rating } : {},
1399
1407
  sort: args.sort,
1400
1408
  limit: args.limit,
1401
1409
  page: args.page
@@ -1589,16 +1597,16 @@ async function main() {
1589
1597
  const transport = new StdioServerTransport();
1590
1598
  await server.connect(transport);
1591
1599
  const shutdown = () => {
1592
- server.close().catch(() => void 0).finally(() => process.exit(0));
1600
+ server.close().catch(() => void 0).finally(() => process2.exit(0));
1593
1601
  };
1594
- process.on("SIGINT", shutdown);
1595
- process.on("SIGTERM", shutdown);
1602
+ process2.on("SIGINT", shutdown);
1603
+ process2.on("SIGTERM", shutdown);
1596
1604
  }
1597
1605
  main().catch((error) => {
1598
- process.stderr.write(
1606
+ process2.stderr.write(
1599
1607
  `[mcp-rule34] fatal: ${error instanceof Error ? error.stack ?? error.message : String(error)}
1600
1608
  `
1601
1609
  );
1602
- process.exit(1);
1610
+ process2.exit(1);
1603
1611
  });
1604
1612
  //# sourceMappingURL=index.js.map