npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@segment/segment-mcp-server-demo

v0.0.2

Published

MCP server for Segment Profile API and AI Copilot tracking

Maintainers

harksinghharksinghfhalim-segmentfhalim-segmentcfreecfreeldelossantosldelossantoshjoonpmhjoonpmceline-segmentceline-segmentpmcanseco-segmentpmcanseco-segmentmasiramasiraamillet89amillet89cholt002cholt002av-segmentav-segmentaghotikaraghotikarvikrant-segmentvikrant-segmentlarryatsegmentlarryatsegmentscruwys1scruwys1kyliepedersenkyliepedersenjinaparkjinaparkcdignam-segmentcdignam-segmentsegmentiosegmentiojrupasinghejrupasinghelateefatlateefatyash-twilioyash-twiliosowjanyasegmentsowjanyasegmentebru.odokebru.odokryanligonryanligonlpediredlalpediredlabrookstaylorjrbrookstaylorjrnithan-twilionithan-twiliodean-huynhdean-huynhwdbettswdbettsn2parkon2parkojayakrishnannairjayakrishnannairrhall-twiliorhall-twiliokarimkeshwanikarimkeshwanityson_segmenttyson_segmentjgabe13jgabe13bgamwellbgamwellpoojasegmentpoojasegmentmaryam.sharifmaryam.sharifwally.tgwally.tgsalolivaressalolivareserikdwerikdwchenxiangzhangchenxiangzhangjusteenjusteenmericssonmericssonprayansh-segmenttprayansh-segmenttjeremylarkinjeremylarkinbsneedbsneeddanieljackinsdanieljackinssegment-sethsegment-sethsayan-das-insayan-das-injames9446james9446priscilla.giattipriscilla.giattinlsunnlsundrew-thompsondrew-thompsonsegment-jsinghsegment-jsinghmcoulibalimcoulibaliandrius-segmentandrius-segmentvalerieernstvalerieernstnithin-bennynithin-bennyainatancincoainatancincoskondamuriskondamuriclintz.segclintz.segreplateroreplateroslenin-twilioslenin-twiliocsayusocsayusoseanhan-segmentseanhan-segmentnevermore2022nevermore2022gilomergilomermarcelopvmarcelopveric.rognereric.rognerkdharaiyakdharaiyajon.anderson-at-segment.comjon.anderson-at-segment.comstacy.songstacy.songrexatsegmentrexatsegmentnickaguilarnickaguilarbradenbeckerbradenbeckerreneewangreneewangdan.laskydan.laskysam.tapiasam.tapialnambalnambavikramkumar19vikramkumar19mpriyad25mpriyad25jeremy.parkerjeremy.parkersmidgessmidgesnageshgolemnageshgolemsudojatinsudojatinpmaidpmaidsethsegmentsethsegmentjair.avilesjair.avilesmanali-bhosalemanali-bhosaleelmoselyeeelmoselyeechtoombschtoombspeterdemartinipeterdemartinivincen7tranvincen7tranlfdelossantoslfdelossantosemmy.byrneemmy.byrnefelttripfelttripsa-jsootersa-jsooterlluque-twiliolluque-twiliokevinburkesegmentkevinburkesegmentafsha-nazim-segafsha-nazim-segsong4yousong4youdavid.anusontarangkul.segmentdavid.anusontarangkul.segmentjyim008jyim008michaelghsegmichaelghsegaishikawakiaishikawakitwjosiahtwjosiahtanya.gupta.segmenttanya.gupta.segmentsindhusegmentsindhusegmentprabhnoor1997prabhnoor1997chihchun-twiliochihchun-twiliopmiller-twiliopmiller-twiliovbatanovvbatanovsimpixelatedsimpixelatedmcullenmeyermcullenmeyerneeharikakondipatineeharikakondipatieric-hydeeric-hydearunlalam-segmentarunlalam-segmentmschaszbergermschaszbergershuvrajit9904shuvrajit9904abhinavsurekaabhinavsurekavaradarajan-twvaradarajan-twimmanojimmanojblangtwilioblangtwiliojsh-wujsh-wusethnutetwiliosethnutetwiliorrivera-segmentrrivera-segmentsegment-adminsegment-adminbgillanbgillantcgilberttcgilbertmckern_segmentmckern_segmentmaneesh.dharma29maneesh.dharma29joetessyjoetessydominicbarnesdominicbarnesmugelstadmugelstadjalexy12jalexy12pmuninpmuninwhaider_twiliowhaider_twilioariel.silvestriariel.silvestrishraddha-twilioshraddha-twiliomichelrmichelrbrandon.scott-segmentbrandon.scott-segmentjfehrman.segmentjfehrman.segmentprayansh-twilioprayansh-twiliodangmai-segmentdangmai-segmentaaronklishaaronklishbrianhumphreystwiliobrianhumphreystwiliormukundanrmukundanashwitha.bgashwitha.bgryanrouleau-segmentryanrouleau-segmentfunlufunlutdibaccotdibaccofauzy.yyfauzy.yynlubchenconlubchencoarubiochavezarubiochavezphillip.thomasphillip.thomasjkusa_segmentjkusa_segmentrollcoderollcodemeg1000meg1000nainy.agrawalnainy.agrawalseg-rustybaileyseg-rustybaileyjbandi-twiliojbandi-twiliosaisagarkappaganthulasaisagarkappaganthulaforgetfulfellowforgetfulfellowpooja.patilpooja.patiljoe.ayoub.segmentjoe.ayoub.segmenthmohanram_seghmohanram_segbrian.aguirrebrian.aguirreenyi.asonyeenyi.asonyefarhan0581farhan0581tbrennanjtbrennanjparag.pandaparag.pandaharsh.vardhanharsh.vardhansshaikh_segmentsshaikh_segmentxinghao.huangxinghao.huangshupadhyayshupadhyayjohn.lee1100john.lee1100kx-segmentkx-segmentsegment_fansegment_fandazu70dazu70sai-patanjalisai-patanjaliemilyjiaemilyjiay.yuy.yuea_segmentea_segmentyli119yli119pooyajpooyajsungju.jinsungju.jinconniechenconniechenbharath.boregowdabharath.boregowdaigracheva-twilioigracheva-twiliobenattwiliobenattwiliomarinheromarinherodobrin.ganevdobrin.ganevalfrimpongalfrimpongbrandonheyer-segmentbrandonheyer-segmentalecjacobs-segmentalecjacobs-segmentcjo2cjo2yashnit-segmentyashnit-segmentdltnbrks-segmentdltnbrks-segmentachandrashekaranachandrashekaranhimanshuphhimanshuphpraguptapraguptatw-dgarciatw-dgarciaalayvoraalayvoraaparna.singhalaparna.singhalynguyenynguyentimmyzsearcytimmyzsearcylweimersegmentlweimersegmentanton-vylushchakanton-vylushchakazhaotwilioazhaotwiliorokatyalrokatyalkjoerreskjoerresmsarafmsarafvikakumarvikakumaraditi.raveeshaditi.raveeshchenchensegmentcomchenchensegmentcomsanket.mishrasanket.mishraodoren_segmentodoren_segmentjxin_twiliojxin_twiliorcheedhallarcheedhallajbasiglio-segmentjbasiglio-segmentviveksainaneesegmentviveksainaneesegmentpriyanshispriyanshispreetyppreetypakash.gautam07akash.gautam07nanotimmnanotimmyshkpryshkprsrivig21srivig21ssunejassunejabala.singareddybala.singareddymoyara2moyara2arjunbhandagearjunbhandageakodankiryakodankiryrodhilton_twiliorodhilton_twiliocdelaomartinezcdelaomartinezgbatragbatraspencerattickspenceratticksegmentseansegmentseansundareswar.jayakumarsundareswar.jayakumarvaibhavnandavaibhavnandabannapplebannapplesrishti-nemasrishti-nemagsolis_segmentgsolis_segmentitsarijitrayitsarijitraybhavanki-segmentbhavanki-segmentnanette.ranesnanette.ranesamigandhiamigandhiguthriesegmentguthriesegmentmiguelpdiaz8miguelpdiaz8mansarimansarisandhya16sandhya16hema-bahirwani-segmenthema-bahirwani-segmentbnakkinabnakkinapraveenugiripraveenugiriighorelaighorelanemery-segmentnemery-segmentwlumsegmentwlumsegmentnat-gridnat-gridneedcaffeineneedcaffeinekbhargavaram-sgkbhargavaram-sgirfan.ali.segmentirfan.ali.segmented-twilion-npmed-twilion-npmaubreysineaubreysinesethgrid_segmentsethgrid_segmentjibrangjibrangseg-leonelsanchesseg-leonelsanchessmccoy-twiliosmccoy-twiliodevthaledevthaleandwivediandwivedipoojapatilsegpoojapatilseggaprabhugaprabhumonusegmentmonusegmentwongwilliamwongwilliamankit.gupta.unthinkableankit.gupta.unthinkableharsh-joshi99harsh-joshi99ehydesegmentehydesegmentabueide-segmentabueide-segmentcaseyk09caseyk09ankigupta92ankigupta92psandquistpsandquistjagsinghjagsinghdcp-twiliodcp-twiliosprajapati89sprajapati89agerbas-segmentagerbas-segmentamitsinglaatsegamitsinglaatsegjoy-twiliojoy-twilioamanda.maamanda.majinesh-twiliojinesh-twilioardev_npmardev_npmnikumar-segment-newnikumar-segment-newsarthak-twiliosarthak-twilionupur-twilionupur-twiliovkundnanivkundnaniprathoresegmentprathoresegmentmmilhansegmmilhansegshubhkrishnashubhkrishnakvivekabhiramkvivekabhiramajsinghsegajsinghsegkkolhe-twiliokkolhe-twilioprassinghprassinghseg-ajasinghseg-ajasinghmdkhan-twmdkhan-twmahitmahitmfkimbellmfkimbelll0adedl0adedjay-savlajay-savlalaksh25laksh25sbommarito-segmentsbommarito-segmentcsmonlaicsmonlaibha_segmentbha_segmentayagrawal7ayagrawal7mayguptamaygupta

Readme

Segment MCP Server

A Model Context Protocol (MCP) server for Segment's Profile API and AI Copilot tracking capabilities. This package provides both a ready-to-use CLI tool and a modular library for building custom MCP servers.

Features

  • 🔌 Multiple Transport Support: Stdio for local development, HTTP for remote deployment
  • 📊 Segment Profile API: Access user profiles, traits, and events
  • 🤖 AI Tracking: Built-in tools for tracking AI conversations and interactions
  • 🔧 Modular Architecture: Use as a library or CLI tool
  • 🛡️ Type Safe: Full TypeScript support
  • 🌐 Multi-Session HTTP: Support for multiple concurrent MCP sessions over HTTP

Installation

npm install segment-mcp-server

Quick Start

As a CLI Tool

# Set your environment variables
export SEGMENT_PROFILE_API_TOKEN="your_token"
export SEGMENT_TRACKING_WRITE_KEY="your_write_key"
export SEGMENT_WORKSPACE_ID="your_workspace_id"
export SEGMENT_SPACE_ID="your_space_id"

# Run with stdio transport (default)
segment-mcp-server

# Run with HTTP transport
export MCP_TRANSPORT=http
export HTTP_PORT=3000
segment-mcp-server

As a Library

import {
  SegmentMcp,
  createStdioTransport,
  createHttpTransport,
  loadConfig,
} from "segment-mcp-server";

// Create the server
const config = loadConfig();
const server = new SegmentMcp({ config });

// Option 1: Stdio transport
const stdioTransport = createStdioTransport();
await server.start(stdioTransport);

// Option 2: HTTP transport
const httpTransport = createHttpTransport();
await server.start(httpTransport);

Modular Architecture

The package is designed with separation of concerns:

// Core server (no transport dependencies)
import { SegmentMcp } from "segment-mcp-server/server";

// Transport utilities
import {
  createStdioTransport,
  createHttpTransport,
} from "segment-mcp-server/transports";

// Configuration utilities
import { loadConfig, validateConfig } from "segment-mcp-server/config";

Transport Options

Stdio Transport

Perfect for local development and CLI usage:

import {
  SegmentMcp,
  createStdioTransport,
  loadConfig,
} from "segment-mcp-server";

const config = loadConfig();
const server = new SegmentMcp({ config });
const transport = createStdioTransport();

await server.start(transport);
console.log("Server running with stdio transport");

HTTP Transport (Single Session)

For simple HTTP deployments:

import {
  SegmentMcp,
  createHttpTransport,
  loadConfig,
} from "segment-mcp-server";

const config = loadConfig();
const server = new SegmentMcp({ config });

const transport = createHttpTransport({
  enableJsonResponse: true,
});

await server.start(transport);
console.log("Server running with HTTP transport");

HTTP Server (Multi-Session)

For production deployments supporting multiple concurrent sessions:

import {
  SegmentMcp,
  createHttpTransportManager,
  loadConfig,
} from "segment-mcp-server";

const config = loadConfig();
config.httpPort = 3000;
config.httpHost = "0.0.0.0";

const server = new SegmentMcp({ config });
const httpManager = createHttpTransportManager(server.getServer(), config);

await httpManager.start();
console.log(`Multi-session HTTP server running on port ${config.httpPort}`);

// Graceful shutdown
process.on("SIGINT", async () => {
  await httpManager.stop();
  process.exit(0);
});

Available Tools

Profile Tools

  • get_profile_traits: Retrieve user profile traits
  • get_profile_events: Get user events and interactions
  • get_profile_past_chat: Access past conversation history

Tracking Tools

  • track_ai_conversation: Track AI conversation events
  • track_ai_query: Track individual AI queries
  • track_ai_feedback: Track user feedback on AI responses
  • track_custom_event: Track custom events
  • identify_user: Identify and update user profiles

Configuration

Environment Variables

# Required
SEGMENT_PROFILE_API_TOKEN=your_profile_api_token
SEGMENT_TRACKING_WRITE_KEY=your_tracking_write_key
SEGMENT_WORKSPACE_ID=your_workspace_id
SEGMENT_SPACE_ID=your_space_id

# Optional
SEGMENT_PROFILE_API_BASE_URL=https://profiles.segment.com
SEGMENT_TRACKING_API_BASE_URL=https://api.segment.io/v1
LOG_LEVEL=info
API_RATE_LIMIT_PER_MINUTE=60

# Transport configuration
MCP_TRANSPORT=stdio  # or "http"
HTTP_PORT=3000
HTTP_HOST=0.0.0.0

Programmatic Configuration

import { SegmentMcp, SegmentConfig } from "segment-mcp-server";

const config: SegmentConfig = {
  profileApiToken:
    "vGzKEqx0hpXIA7z0JwRp_0Fw0BeUrL-wdLPxwrCeV8smuKnHnlDgbjo_nRwsZMnsWofjVkdwQiHDCqpI3XI0aWYgE8Bjeq-oZpO8UDHvVYRteMcfzPykgZnaI5_24xOFXHK8Fp9hrIhTpYYerQV_ZZbLmqyoB5eueHvGq5W_BMCzc-fFDwVqq2ByjhY5f_xo-kJ_LqhhThxrtFO1DWIFEX-zyq5VbLyzGCBnKu7jfxf1L82ZQV5mRN00ICpp-W99VQ==",
  trackingWriteKey: "rLNeLldLBz1tJ9jOjTGeU8hEQywSaFhS",
  workspaceId: "9rPVQSx1K1",
  spaceId: "spa_1bnL856M3JaIoKvx7fQQu0uCvqu",
  profileApiBaseUrl: "https://profiles.segment.com",
  trackingApiBaseUrl: "https://api.segment.io/v1",
  logLevel: "info",
  rateLimit: 60,
  transport: "http",
  httpPort: 3000,
  httpHost: "0.0.0.0",
};

const server = new SegmentMcp({
  config,
  name: "my-segment-server",
  version: "1.0.0",
});


## Examples

Run the included examples:

```bash
# Basic usage examples
npm run example:basic stdio
npm run example:basic http

# HTTP server management examples
npm run example:http manager
npm run example:http utility

HTTP API Endpoints

When running in HTTP mode, the following endpoints are available:

  • POST /mcp - Main MCP protocol endpoint
  • GET /mcp - Server-sent events for notifications (optional)
  • DELETE /mcp - Session termination
  • GET /health - Health check endpoint

Session Management

HTTP transport supports multiple concurrent sessions. Each session is identified by the Mcp-Session-Id header:

# Initialize a new session
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","clientInfo":{"name":"test-client","version":"1.0.0"}}}'

# Use the returned session ID for subsequent requests
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -H "Mcp-Session-Id: your-session-id" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'

Development

# Install dependencies
npm install

# Build the project
npm run build

# Run in development mode
npm run dev

# Clean build artifacts
npm run clean

TypeScript Support

Full TypeScript definitions are included:

import {
  SegmentMcp,
  SegmentMcpOptions,
  SegmentConfig,
  HttpTransportOptions,
  HttpTransportManager,
} from "segment-mcp-server";

License

ISC

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request