@enky-yy/fauxmcp 0.1.0 → 0.2.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.
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  import { serverInfo } from "./lib/env.js";
3
2
  import { runServer } from "./server.js";
4
3
  const args = process.argv.slice(2);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACnD,OAAO,CAAC,GAAG,CACT;QACE,YAAY,UAAU,CAAC,OAAO,uCAAuC;QACrE,EAAE;QACF,yDAAyD;QACzD,0CAA0C;QAC1C,6CAA6C;QAC7C,EAAE;QACF,sEAAsE;QACtE,+DAA+D;QAC/D,EAAE;QACF,0CAA0C;KAC3C,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACnC,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| "scrape" | "api" | "generated";
2
+ export interface DatasetMeta {
3
+ /** Stable slug used in resource URIs and tool calls. */
4
+ id: string;
5
+ /** Human-friendly name. */
6
+ name: string;
7
+ /** File name inside the cache directory. */
8
+ file: string;
9
+ /** Data format, e.g. csv, json, sql, md. */
10
+ format: string;
11
+ kind: DatasetKind;
12
+ sourceUrl?: string;
13
+ rows?: number;
14
+ bytes: number;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ }
18
+ export declare function slugify(name: string): string;
19
+ export declare function loadIndex(): Promise<DatasetMeta[]>;
20
+ export interface SaveDatasetInput {
21
+ name: string;
22
+ content: string;
23
+ format: string;
24
+ kind: DatasetKind;
25
+ sourceUrl?: string;
26
+ rows?: number;
27
+ }
28
+ /** Persist a dataset and return its metadata (overwrites same-named datasets). */
29
+ export declare function saveDataset(input: SaveDatasetInput): Promise<DatasetMeta>;
30
+ export interface LoadedDataset {
31
+ meta: DatasetMeta;
32
+ content: string;
33
+ }
34
+ /** Read a cached dataset by id (or file name). */
35
+ export declare function getDataset(id: string): Promise<LoadedDataset | null>;
36
+ /** Find a cached dataset previously downloaded from the same URL. */
37
+ export declare function findByUrl(url: string): Promise<DatasetMeta | undefined>;
38
+ /** List cached datasets, most recently updated first. */
39
+ export declare function listDatasets(): Promise<DatasetMeta[]>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Runtime configuration. Every guardrail is overridable through environment
3
+ * variables so that the defaults protect you without ever hard-blocking you.
4
+ */
5
+ export declare const config: {
6
+ /** Maximum number of generated rows a single call may request. */
7
+ readonly maxRows: number;
8
+ /** Maximum download size in megabytes. */
9
+ readonly maxSizeMb: number;
10
+ /** Fetch timeout in milliseconds. */
11
+ readonly fetchTimeoutMs: number;
12
+ /** Number of rows shown inline in tool responses. */
13
+ readonly previewRows: number;
14
+ /** Maximum characters in any single inline preview. */
15
+ readonly previewChars: number;
16
+ /** Maximum characters per table cell in inline previews. */
17
+ readonly maxCellChars: number;
18
+ /** Maximum number of HTML tables scraped from one page. */
19
+ readonly maxTables: number;
20
+ /** Where downloaded and generated datasets are cached. */
21
+ readonly cacheDir: string;
22
+ };
23
+ export declare const serverInfo: {
24
+ readonly name: "fauxmcp";
25
+ readonly version: "0.1.0";
26
+ };
@@ -0,0 +1,26 @@
1
+ import { type Faker } from "@faker-js/faker";
2
+ export declare const SUPPORTED_LOCALES: string[];
3
+ export declare const FIELD_TYPES: readonly ["id", "uuid", "firstName", "lastName", "fullName", "username", "email", "phone", "avatar", "city", "country", "countryCode", "streetAddress", "zipCode", "latitude", "longitude", "company", "jobTitle", "department", "url", "domainName", "ipv4", "emoji", "color", "productName", "integer", "float", "boolean", "date", "datetime", "time", "price", "amount", "currencyCode", "word", "sentence", "paragraph", "isbn", "creditCardNumber", "iban", "enum", "constant"];
4
+ export type FieldType = (typeof FIELD_TYPES)[number];
5
+ export interface FieldSpec {
6
+ name: string;
7
+ type: FieldType;
8
+ /** Values to pick from when `type` is `enum` (required for enums). */
9
+ values?: Array<string | number | boolean>;
10
+ /** Fixed value when `type` is `constant` (required for constants). */
11
+ value?: string | number | boolean;
12
+ /** Inclusive lower bound for numeric field types. */
13
+ min?: number;
14
+ /** Inclusive upper bound for numeric field types. */
15
+ max?: number;
16
+ }
17
+ export type Row = Record<string, string | number | boolean>;
18
+ export declare const PRESETS: Record<string, FieldSpec[]>;
19
+ export declare const PRESET_NAMES: readonly ["people", "products", "orders", "companies"];
20
+ export type PresetName = (typeof PRESET_NAMES)[number];
21
+ /** Resolve a locale name to a Faker instance, falling back to English. */
22
+ export declare function getFaker(locale?: string, seed?: number): Faker;
23
+ /** Generate a single field value for the given row index. */
24
+ export declare function generateField(faker: Faker, spec: FieldSpec, index: number, reference?: Date): string | number | boolean;
25
+ /** Generate `count` rows for the given field specs. */
26
+ export declare function generateRows(fields: FieldSpec[], count: number, locale?: string, seed?: number): Row[];
@@ -0,0 +1,21 @@
1
+ export interface FetchResult {
2
+ text: string;
3
+ contentType: string;
4
+ finalUrl: string;
5
+ bytes: number;
6
+ }
7
+ export declare class FetchLimitError extends Error {
8
+ }
9
+ /**
10
+ * Fetch a URL with guardrails:
11
+ * - http(s) only
12
+ * - cloud metadata / link-local hosts blocked (unless FAUX_ALLOW_METADATA=1)
13
+ * - redirects followed manually so every hop is re-validated
14
+ * - a timeout and a streaming byte cap
15
+ *
16
+ * Throws FetchLimitError when the response exceeds the configured size.
17
+ */
18
+ export declare function guardedFetch(url: string, init?: RequestInit, opts?: {
19
+ timeoutMs?: number;
20
+ maxBytes?: number;
21
+ }): Promise<FetchResult>;
@@ -0,0 +1,27 @@
1
+ import type { Row } from "./faker.js";
2
+ export type OutputFormat = "json" | "csv" | "tsv" | "sql" | "markdown";
3
+ export declare function columnsOf(rows: Row[]): string[];
4
+ export declare function toJson(rows: Row[]): string;
5
+ export interface DelimitedOptions {
6
+ /** Prefix formula-like string cells so spreadsheets treat them as text. */
7
+ neutralizeFormulas?: boolean;
8
+ }
9
+ export declare function toDelimited(rows: Row[], delimiter: string, options?: DelimitedOptions): string;
10
+ export declare function toCsv(rows: Row[], options?: DelimitedOptions): string;
11
+ /** Build portable SQL: CREATE TABLE + INSERT statements. */
12
+ export declare function toSql(rows: Row[], tableName: string): string;
13
+ /** Render rows as a GitHub-flavored Markdown table. */
14
+ export declare function toMarkdownTable(rows: Row[], options?: {
15
+ maxRows?: number;
16
+ maxColumns?: number;
17
+ maxCellLength?: number;
18
+ }): string;
19
+ export declare function formatRows(rows: Row[], format: OutputFormat, tableName?: string, options?: DelimitedOptions): string;
20
+ /**
21
+ * Wrap text in a code fence long enough that content containing backticks
22
+ * cannot break out of the block.
23
+ */
24
+ export declare function fenced(text: string, language?: string): string;
25
+ export declare function extensionFor(format: string): string;
26
+ export declare function formatBytes(bytes: number): string;
27
+ export declare function truncate(text: string, max: number): string;
@@ -0,0 +1,14 @@
1
+ import type { Row } from "./faker.js";
2
+ export interface ExtractedTable {
3
+ index: number;
4
+ caption?: string;
5
+ headers: string[];
6
+ rows: string[][];
7
+ }
8
+ /**
9
+ * Extract every HTML table from a page. Handles header rows declared with
10
+ * `<th>`; otherwise generates `column_1..n` headers and treats the first row
11
+ * as data. Nested tables are flattened by the outer table scan.
12
+ */
13
+ export declare function extractTables(html: string, maxTables?: number): ExtractedTable[];
14
+ export declare function tableToRows(table: ExtractedTable): Row[];
@@ -0,0 +1,12 @@
1
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
+ /** Build a successful text tool result. */
3
+ export declare function ok(text: string): CallToolResult;
4
+ /** Build an error tool result (shown to the model, not thrown). */
5
+ export declare function fail(message: string): CallToolResult;
6
+ /** Extract a readable message from an unknown thrown value. */
7
+ export declare function errorMessage(err: unknown): string;
8
+ /**
9
+ * Wrap a handler so thrown errors become tool errors instead of crashing the
10
+ * server. Keeps every tool's failure mode consistent.
11
+ */
12
+ export declare function withErrors<A>(handler: (args: A) => Promise<CallToolResult>): (args: A) => Promise<CallToolResult>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Network safety helpers.
3
+ *
4
+ * We block cloud metadata endpoints and link-local addresses by default to
5
+ * reduce the blast radius of prompt-injected fetches (SSRF). Loopback and
6
+ * private ranges stay allowed so local dev servers remain usable; set
7
+ * FAUX_ALLOW_METADATA=1 to disable this blocklist entirely.
8
+ */
9
+ /** True when the metadata blocklist has been explicitly disabled. */
10
+ export declare function metadataBlockingDisabled(): boolean;
11
+ /** True when the hostname points at a metadata service or link-local range. */
12
+ export declare function isMetadataHost(hostname: string): boolean;
13
+ /** Throw when the URL targets a blocked metadata/link-local host. */
14
+ export declare function assertNetworkAllowed(url: URL): void;
15
+ /** Throw unless the URL uses http: or https:. */
16
+ export declare function assertHttpProtocol(url: URL): void;
17
+ /** Strip embedded credentials before a URL appears in an error message. */
18
+ export declare function redactUrl(url: URL | string): string;
@@ -0,0 +1,6 @@
1
+ import { type McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ /**
3
+ * Expose cached datasets as MCP resources so clients that support resources can
4
+ * browse and read them directly, without a tool round-trip.
5
+ */
6
+ export declare function registerResources(server: McpServer): void;
@@ -0,0 +1,5 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ /** Build a configured MCP server (all tools + resources registered). */
3
+ export declare function createServer(): McpServer;
4
+ /** Start the server over stdio. */
5
+ export declare function runServer(): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerGenerationTools(server: McpServer): void;
@@ -0,0 +1,8 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ /**
3
+ * Cache key for API responses. GETs key on the URL alone so existing caches
4
+ * keep working; every other method mixes in the method and a body hash so a
5
+ * POST/PUT response can never be served back as a GET (or vice versa).
6
+ */
7
+ export declare function apiCacheKey(method: string, url: string, body: string | undefined): string;
8
+ export declare function registerRetrievalTools(server: McpServer): void;
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@enky-yy/fauxmcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "The data toolbox MCP — generate realistic fake data, fetch datasets from URLs, scrape HTML tables, and query public APIs.",
5
5
  "license": "MIT",
6
6
  "author": "Enky-yy",
7
7
  "type": "module",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
8
10
  "repository": {
9
11
  "type": "git",
10
12
  "url": "https://github.com/Enky-yy/fauxmcp.git"