<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>
This module allows you to:
const { Server, RCON, MasterServer } = require('@fabricio-191/valve-server-query');
Some of the games where it works with are:
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);
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);
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');
$ claude mcp add valve-server-query \
-- python -m otcore.mcp_server <graph>