Skip to content

Latest commit

 

History

History
175 lines (129 loc) · 9.13 KB

CONTRIBUTING.md

File metadata and controls

175 lines (129 loc) · 9.13 KB

Contributing to Steam MCP Server

Prerequisites

Setup

git clone https://github.com/TMHSDigital/steam-mcp.git
cd steam-mcp
npm install
npm run build

Set your API key for testing:

# PowerShell
$env:STEAM_API_KEY = "your_key_here"

# Bash
export STEAM_API_KEY="your_key_here"

Run in development mode (auto-reloads on changes):

npm run dev

CLAUDE.md maps the source tree and the patterns every tool follows; it is the fastest way in.

Adding a new tool

  1. Create a new file in src/tools/ (e.g. src/tools/getPlayerCount.ts).

  2. Follow the existing pattern - export a register function that calls server.registerTool() (never the deprecated server.tool()):

import { z } from "zod";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { steamApiUrl, steamFetch, errorResponse } from "../utils/steam-api.js";
import { READ_ONLY } from "../utils/annotations.js";

const inputSchema = {
  appid: z.number().int().positive().describe("Steam application ID"),
};

// Optional: declare the result shape and return it as structuredContent too.
const outputSchema = {
  appid: z.number().int(),
  player_count: z.number().int().describe("Concurrent players right now"),
};

export function register(server: McpServer): void {
  server.registerTool(
    "steam_getPlayerCount",
    {
      title: "Get Player Count",
      description:
        "Get the current number of concurrent players for a Steam app. No API key required.",
      inputSchema,
      outputSchema,
      annotations: READ_ONLY,
    },
    async ({ appid }) => {
      try {
        const url = steamApiUrl("/ISteamUserStats/GetNumberOfCurrentPlayers/v1/", { appid });
        const data = (await steamFetch(url)) as { response?: { player_count?: number; result?: number } };
        if (data.response?.result !== 1 || data.response.player_count === undefined) {
          return errorResponse(new Error(`No player count data available for app ${appid}.`));
        }

        // Compact JSON (no indentation): results go into the agent's context.
        const structured = { appid, player_count: data.response.player_count };
        return {
          content: [{ type: "text", text: JSON.stringify(structured) }],
          structuredContent: structured,
        };
      } catch (error) {
        return errorResponse(error);
      }
    },
  );
}

Pick annotations from src/utils/annotations.ts: READ_ONLY for Steam reads, LOCAL_ONLY for tools that never touch the network, LIVE_WRITE or LIVE_WRITE_IDEMPOTENT for confirm-gated mutations.

  1. Add it to a toolset in src/tools/index.ts (store, community, publisher, mutations, sdk, assets, build, or deploy). Live Partner API writes go in mutations, which is off by default. Anything that uploads or changes a live build goes in deploy, which also needs STEAM_MCP_ENABLE_DEPLOY=1 and never loads over HTTP:
import { register as registerGetPlayerCount } from "./getPlayerCount.js";
// ...
export const TOOLSETS = {
  store: [registerGetAppDetails, registerGetPlayerCount, /* ... */],

Add the tool to the README toolset table too. 4. Every tool description, keyless ones included, must say which key it needs with one of these exact phrases, which the site build reads (site/build.ts keyNeed): "No API key required", "Requires STEAM_API_KEY", "publisher key", or "Financial API Group key". Tools in the sdk, assets, and build toolsets are local and exempt. If the tool needs a key, use requireApiKey() from steam-api.ts.

  1. If the tool performs a live mutation (inventory grant, achievement/stat write, leaderboard write, Workshop metadata update, Partner-admin upload, or similar), spread confirmSchema from src/utils/confirm.ts, call refuseIfUnconfirmed before any network I/O, run the dry-run branch before requireApiKey(), and prepend a capability warning to the tool description. Do not add a new write tool that can send unconfirmed. A deploy tool also calls the gates in src/build/deploy.ts (refuseLiveDeploy for agent sessions, refuseProtectedBranch for the default branch) before it runs anything. Read-only Steam POSTs (for example GetPublishedFileDetails) are not mutations and must not use this gate.

  2. Add a row for the tool to the README tool table and bump the tool counts (README, CLAUDE.md, package.json description). A new Steam endpoint also gets a row in the README endpoint table (and its count), a new outputSchema goes in the README "Typed output" list, and a new prompt gets a row in the README prompts table. Then run npm run site and commit the regenerated docs/ pages, which list every tool. npm test (docs-drift.test.ts) fails until they all match.

  3. Add a handler test under src/tools/__tests__/ that stubs fetch with a fixture (handlers.test.ts fails until every tool has a success and an error case), and build and test:

npm run build
npm test

The README demo

The animated terminal at the top of the README (assets/demo-dark.svg, assets/demo-light.svg) is generated by node scripts/render-demo-svg.mjs. It only shows real tool output: to change a scene, run the tool, paste what it returned into the script, and regenerate both files.

Code style

  • TypeScript with strict mode enabled
  • Never use em dashes. Use a regular dash or rewrite the sentence.
  • Never hardcode API keys. Always read from STEAM_API_KEY environment variable.
  • Every tool should have a clear description and well-typed zod input schema with .describe() on each field.
  • Wrap all tool handlers in try/catch and use errorResponse() for error formatting.
  • Live mutations must use the shared confirm gate (confirmSchema, refuseIfUnconfirmed, dry-run before requireApiKey()).

Pull request guidelines

  • One tool per PR when adding new tools
  • Include the Steam API endpoint URL in the PR description
  • Note whether the endpoint requires authentication
  • Test with real Steam API calls before submitting
  • Keep changes focused - avoid unrelated refactors in the same PR
  • Make sure npm run build, npm run typecheck, and npm test pass

Release checklist

The version lives in package.json, mirrored in server.json and mcpb/manifest.json (a test enforces that they match). Both servers read it at runtime from src/version.ts.

  1. Move the [Unreleased] entries in CHANGELOG.md under a new version heading with today's date.
  2. npm version <patch|minor|major> --no-git-tag-version (updates package.json and package-lock.json), and set both version fields in server.json and the version in mcpb/manifest.json to the same value. npm test fails until they match.
  3. If the tool list changed, update the counts in package.json description, the README badge, summary line, and tool tables, and CLAUDE.md. npm test fails until they match the registered tools.
  4. If a supported-version boundary moved, update the table in SECURITY.md.
  5. Run npm run site and commit the regenerated docs/ pages: they show the version, so npm version makes them stale.
  6. npm run build && npx tsc -p tsconfig.partner.json && npm run typecheck && npm test
  7. Commit, push, and publish a GitHub release tagged vX.Y.Z. The publish workflow ships it to npm, then lists it in the official MCP Registry from server.json, and attaches the Claude Desktop extension (steam-mcp.mcpb, built by npm run mcpb) to the release. The Docker workflow pushes ghcr.io/tmhsdigital/steam-mcp.
  8. Check the publish run. If the MCP Registry job fails because npm does not have the new version yet, wait until npm view @tmhs/steam-mcp version shows it and rerun only the failed job (gh run rerun <run id> --failed).

Developer Certificate of Origin and Inbound License Grant

This project uses CC-BY-ND-4.0 as its outbound license, which forbids derivatives. Every pull request is a derivative. Contributions are accepted inbound under a broader grant via the Developer Certificate of Origin (DCO), which resolves the conflict so the project can accept and redistribute contributions.

Required grant

By submitting a contribution to this repository, you certify that you have the right to do so under the Developer Certificate of Origin (DCO) 1.1, and you grant TMHSDigital a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license to use, reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute your contribution under the project's current license (CC-BY-ND-4.0) or any successor license chosen by the project.

DCO sign-off

Every commit in a pull request must have a Signed-off-by: trailer matching the commit author:

Signed-off-by: Jane Developer <jane@example.com>

Signing is done at commit time:

git commit -s -m "feat: add new skill"

The GitHub DCO App enforces this on every PR.

For the full inbound/outbound model and rationale, see standards/licensing.md in the Developer-Tools-Directory meta-repo.