Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ still `needs-review` (with its open question), so a build can stop on it. In a c
does the same and reads `site/dist/data.json` when a build is there; `--data <file or https URL>` picks another copy.

`site/cli/mcp.mjs` is a Model Context Protocol server (stdio, no dependencies) with the tools `search_assets`,
`get_asset`, `check_license` and `list_stacks`. In Claude Desktop, Cursor or another MCP client, from a clone:
`get_asset`, `check_license` and `list_stacks`. Start it without cloning the repository by using this client configuration in Claude Desktop, Cursor or another MCP client:

```json
{ "mcpServers": { "free-game-dev-assets": { "command": "node", "args": ["/path/to/Free-Game-Dev-Assets/site/cli/mcp.mjs"] } } }
{ "mcpServers": { "free-game-dev-assets": { "command": "npx", "args": ["-y", "github:TMHSDigital/Free-Game-Dev-Assets", "mcp"] } } }
```

This runs the `mcp` subcommand exposed by the existing `fgda` CLI. To use a local file or another data URL, append `--data` and its value after `mcp` in the arguments.

## How to cite

The repository has a [`CITATION.cff`](../CITATION.cff), and GitHub's "Cite this repository" button renders it. In text:
Expand Down
7 changes: 5 additions & 2 deletions site/cli/fgda.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ import { fileURLToPath } from "node:url";
import { parseArgs } from "node:util";
import { checkLicense, getAsset, listStacks, searchAssets } from "../lib/catalog-query.mjs";
import { loadData } from "./data.mjs";
import { main as runMcp } from "./mcp.mjs";

const USAGE = `usage: fgda search [words] [--license L] [--category C] [--commercial] [--no-attribution] [--engine E] [--format F] [--limit N]
fgda get <id>
fgda check <id> [--engine E] [--non-commercial]
fgda stacks
fgda mcp [--data <file|https URL>]
options: --data <file|https URL> --json`;

const line = (a) =>
`${a.id} ${a.name}\n ${a.license}${a.commercial === true ? ", commercial OK" : a.commercial === "varies" ? ", per-file" : a.commercial === false ? ", NOT commercial" : ", commercial ?"}${a.attribution_required === true ? ", credit required" : a.attribution_required === false ? ", no credit" : ""}${a.engine_lock ? `, ${a.engine_lock} only` : ""}; ${a.status}; read ${a.verified || "never"}\n ${a.page}`;

export async function main(argv = process.argv.slice(2), out = (s) => process.stdout.write(`${s}\n`)) {
export async function main(argv = process.argv.slice(2), out = (s) => process.stdout.write(`${s}\n`), runMcpServer = runMcp) {
const { values: o, positionals } = parseArgs({
args: argv,
allowPositionals: true,
Expand All @@ -49,6 +51,7 @@ export async function main(argv = process.argv.slice(2), out = (s) => process.st
out(USAGE);
return o.help ? 0 : 2;
}
if (cmd === "mcp") return runMcpServer(o.data ? ["--data", o.data] : []);
const data = await loadData(o.data);
const print = (value, text) => out(o.json ? JSON.stringify(value, null, 2) : text);
if (cmd === "search") {
Expand Down Expand Up @@ -80,7 +83,7 @@ export async function main(argv = process.argv.slice(2), out = (s) => process.st
}

if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
main().then((code) => process.exit(code), (err) => {
main().then((code) => { if (code !== undefined) process.exit(code); }, (err) => {
console.error(err.message);
process.exit(2);
});
Expand Down
9 changes: 5 additions & 4 deletions site/cli/mcp.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* no dependencies: newline-delimited JSON-RPC 2.0, the tools capability
* only. Tools: search_assets, get_asset, check_license, list_stacks.
* node site/cli/mcp.mjs [--data <file|https URL>]
* Or through the CLI: fgda mcp [--data <file|https URL>]
* Client config (Claude Desktop, Cursor and others):
* { "command": "node", "args": ["/path/to/Free-Game-Dev-Assets/site/cli/mcp.mjs"] }
* { "command": "npx", "args": ["-y", "github:TMHSDigital/Free-Game-Dev-Assets", "mcp"] }
*/
import path from "node:path";
import readline from "node:readline";
Expand Down Expand Up @@ -85,9 +86,9 @@ export function handle(msg, data) {
}
}

async function main() {
const i = process.argv.indexOf("--data");
const data = await loadData(i === -1 ? undefined : process.argv[i + 1]);
export async function main(argv = process.argv.slice(2)) {
const i = argv.indexOf("--data");
const data = await loadData(i === -1 ? undefined : argv[i + 1]);
const rl = readline.createInterface({ input: process.stdin });
rl.on("line", (raw) => {
if (!raw.trim()) return;
Expand Down
5 changes: 5 additions & 0 deletions site/lib/lib.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2908,6 +2908,11 @@ await section("catalog queries, CLI and MCP (#115)", async () => {
const json = [];
eq("cli: search exits 0", await main(["search", "pixel", "--license", "cc-by", "--json", "--data", file], (s) => json.push(s)), 0);
eq("cli: --json is parseable", JSON.parse(json.join("\n"))[0].id, "b");
const { main: mcpMain } = await import("../cli/mcp.mjs");
eq("mcp: server entry point is importable", typeof mcpMain, "function");
let mcpArgs;
eq("cli: mcp subcommand starts the server", await main(["mcp", "--data", file], () => {}, async (args) => { mcpArgs = args; return 0; }), 0);
eq("cli: mcp forwards the data option", mcpArgs.join(" "), `--data ${file}`);
} finally {
fsm.rmSync(file, { force: true });
}
Expand Down