MCPcopy Index your code
hub / github.com/Fabricio-191/valve-server-query

github.com/Fabricio-191/valve-server-query @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
258 symbols 551 edges 25 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README
<a href="https://fabricio-191.github.io/docs/valve-server-query/" rel="prefetch">
    <img src="https://raw.githubusercontent.com/Fabricio-191/docs/main/src/static/docs1.png">
</a>

Buy Me A Coffee Discord PayPal

This module allows you to:

  • Easily make queries to servers running valve games
  • Make queries to valve master servers
  • Use a remote console to control your server remotely

Links

An implementation of valve protocols

const { Server, RCON, MasterServer } = require('@fabricio-191/valve-server-query');

Some of the games where it works with are:

  • Counter-Strike
  • Counter-Strike: Global Offensive
  • Garry's Mod
  • Half-Life
  • Team Fortress 2
  • Day of Defeat
  • The ship

Examples

Server

const server = new Server({
  ip: '0.0.0.0',
  port: 27015,
  timeout: 3000,
});

const info = await server.getInfo();
console.log(info);

const players = await server.getPlayers();
console.log(players);

const rules = await server.getRules();
console.log(rules);

console.log(server.lastPing);

Master Server

const servers = await MasterServer({
  quantity: 1000,
  region: 'US_EAST',
  timeout: 3000,
});

//servers is an array if 'ip:port' strings, see the docs
console.log(servers);

RCON

const rcon = await RCON({
  ip: '0.0.0.0',
  port: 27015, //RCON port
  password: 'your RCON password'
});

rcon.on('disconnect', async (reason) => {
  console.log('disconnected', reason);
  try{
    await rcon.reconnect();
  }catch(e){
    console.log('reconnect failed', e.message);
  }
});

rcon.on('passwordChanged', async () => {
  const password = await getNewPasswordSomehow();
  try{
    await rcon.authenticate(password);
  }catch(e){
    console.error('Failed to authenticate with new password', e.message);
  }
});

const response = await rcon.exec('sv_gravity 1000');

Full docs

Extension points exported contracts — how you extend this code

Throttler (Interface)
(no doc) [4 implementers]
src/MasterServer/connection.ts
RCON (Interface)
(no doc)
src/RCON/RCON.ts
Options (Interface)
(no doc)
src/Server/serverWatch.ts
BaseData (Interface)
(no doc)
src/Base/options.ts
BaseInfo (Interface)
(no doc)
scripts/fake server/utils.ts
RCONPacket (Interface)
(no doc)
src/RCON/connection.ts
Events (Interface)
(no doc)
src/Server/serverWatch.ts
MasterServerData (Interface)
(no doc)
src/Base/options.ts

Core symbols most depended-on inside this repo

byte
called by 38
scripts/fake server/utils.ts
on
called by 21
src/RCON/RCON.ts
byte
called by 19
src/Base/utils.ts
byte
called by 18
src/Base/utils.ts
string
called by 16
scripts/fake server/utils.ts
map
called by 13
src/MasterServer/filter.ts
exec
called by 13
src/RCON/RCON.ts
_add
called by 12
src/MasterServer/filter.ts

Shape

Method 140
Function 52
Class 35
Interface 30
Enum 1

Languages

TypeScript100%

Modules by API surface

src/MasterServer/filter.ts28 symbols
src/Server/serverWatch.ts27 symbols
src/Base/utils.ts25 symbols
src/MasterServer/connection.ts19 symbols
src/Server/parsers.ts18 symbols
scripts/fake server/index.ts18 symbols
src/RCON/RCON.ts17 symbols
src/Server/server.ts16 symbols
scripts/fake server/utils.ts16 symbols
src/RCON/connection.ts15 symbols
src/Base/connection.ts11 symbols
src/Server/connection.ts10 symbols

For agents

$ claude mcp add valve-server-query \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact