@utilix-tech/mcp 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  Full release notes for all Utilix surfaces (browser tools, REST API, SDKs, MCP server) live at [utilix.tech/changelog](https://utilix.tech/changelog). This file tracks just this package.
4
4
 
5
+ ## 0.29.0
6
+ - Add `read_video_info` tool: duration, resolution, and video/audio codec identifiers from an MP4 (ISO BMFF moov box) or WebM (EBML/Matroska Segment) container header, with no frame decoding or transcoding.
7
+
5
8
  ## 0.28.0
6
9
  - Add `calculate_rule_of_72` tool: estimate years to double an investment from a rate, or the rate needed to double in a given number of years, alongside the exact logarithmic result.
7
10
  - Add `read_flac_info` tool: sample rate, channels, bit depth, total samples, and duration from a FLAC file's STREAMINFO block, plus Vorbis comment tags when present.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @utilix-tech/mcp
2
2
 
3
- MCP server exposing 143 developer utility tools to Claude, Cursor, VS Code Copilot, and any [Model Context Protocol](https://modelcontextprotocol.io) compatible AI assistant.
3
+ MCP server exposing 144 developer utility tools to Claude, Cursor, VS Code Copilot, and any [Model Context Protocol](https://modelcontextprotocol.io) compatible AI assistant.
4
4
 
5
5
  No API key required. All tools run locally. Requires Node.js 18 or later.
6
6
 
@@ -286,6 +286,11 @@ claude mcp add utilix -- npx -y @utilix-tech/mcp
286
286
  | `read_id3_tags` | Read title, artist, album, year, genre, comment, and track number from an MP3's ID3 tags: no audio library required |
287
287
  | `read_flac_info` | Read sample rate, channels, bit depth, total samples, and duration from a FLAC file's STREAMINFO block, plus Vorbis comment tags if present: no audio library required |
288
288
 
289
+ ### Video (1 tool)
290
+ | Tool | Description |
291
+ |------|-------------|
292
+ | `read_video_info` | Read duration, resolution, and video/audio codec identifiers from an MP4 (ISO BMFF) or WebM (EBML/Matroska) file's container header: no frame decoding, demuxing, or transcoding |
293
+
289
294
  ## Requirements
290
295
 
291
296
  - Node.js 18+
package/dist/index.js CHANGED
@@ -4699,5 +4699,265 @@ server.tool(
4699
4699
  return text(JSON.stringify(result, null, 2));
4700
4700
  }
4701
4701
  );
4702
+ function _videoReadU32BE(bytes, offset) {
4703
+ return (bytes[offset] << 24 | bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3]) >>> 0;
4704
+ }
4705
+ function _videoReadU64BE(bytes, offset) {
4706
+ return _videoReadU32BE(bytes, offset) * 4294967296 + _videoReadU32BE(bytes, offset + 4);
4707
+ }
4708
+ function _videoReadAscii4(bytes, offset) {
4709
+ return String.fromCharCode(bytes[offset], bytes[offset + 1], bytes[offset + 2], bytes[offset + 3]);
4710
+ }
4711
+ function _readMp4Boxes(bytes, start, end) {
4712
+ const boxes = [];
4713
+ let offset = start;
4714
+ while (offset + 8 <= end) {
4715
+ let size = _videoReadU32BE(bytes, offset);
4716
+ const type = _videoReadAscii4(bytes, offset + 4);
4717
+ let headerSize = 8;
4718
+ if (size === 1) {
4719
+ if (offset + 16 > end) break;
4720
+ size = _videoReadU64BE(bytes, offset + 8);
4721
+ headerSize = 16;
4722
+ } else if (size === 0) {
4723
+ size = end - offset;
4724
+ }
4725
+ if (size < headerSize || offset + size > end) break;
4726
+ boxes.push({ type, start: offset + headerSize, end: offset + size });
4727
+ offset += size;
4728
+ }
4729
+ return boxes;
4730
+ }
4731
+ function _findMp4Box(boxes, type) {
4732
+ return boxes.find((b) => b.type === type);
4733
+ }
4734
+ function _parseMp4Mvhd(bytes, box) {
4735
+ const o = box.start;
4736
+ if (o >= box.end) return null;
4737
+ const version = bytes[o];
4738
+ if (version === 1) {
4739
+ if (o + 32 > box.end) return null;
4740
+ return { timescale: _videoReadU32BE(bytes, o + 20), duration: _videoReadU64BE(bytes, o + 24) };
4741
+ }
4742
+ if (o + 20 > box.end) return null;
4743
+ return { timescale: _videoReadU32BE(bytes, o + 12), duration: _videoReadU32BE(bytes, o + 16) };
4744
+ }
4745
+ function _parseMp4Tkhd(bytes, box) {
4746
+ const o = box.start;
4747
+ if (o >= box.end) return null;
4748
+ const version = bytes[o];
4749
+ const fixedFieldsSize = version === 1 ? 4 + 8 + 8 + 4 + 4 + 8 : 4 + 4 + 4 + 4 + 4 + 4;
4750
+ const afterDuration = o + fixedFieldsSize;
4751
+ const matrixStart = afterDuration + 8 + 2 + 2 + 2 + 2;
4752
+ const widthOffset = matrixStart + 36;
4753
+ if (widthOffset + 8 > box.end) return null;
4754
+ return { width: _videoReadU32BE(bytes, widthOffset) / 65536, height: _videoReadU32BE(bytes, widthOffset + 4) / 65536 };
4755
+ }
4756
+ function _parseMp4Hdlr(bytes, box) {
4757
+ const o = box.start;
4758
+ if (o + 12 > box.end) return null;
4759
+ return _videoReadAscii4(bytes, o + 8);
4760
+ }
4761
+ function _parseMp4StsdCodec(bytes, box) {
4762
+ const o = box.start;
4763
+ if (o + 8 > box.end) return null;
4764
+ const entryCount = _videoReadU32BE(bytes, o + 4);
4765
+ if (entryCount < 1) return null;
4766
+ const entryStart = o + 8;
4767
+ if (entryStart + 8 > box.end) return null;
4768
+ return _videoReadAscii4(bytes, entryStart + 4);
4769
+ }
4770
+ function _parseMp4StsdVideoDims(bytes, box) {
4771
+ const o = box.start;
4772
+ if (o + 8 > box.end) return null;
4773
+ const entryCount = _videoReadU32BE(bytes, o + 4);
4774
+ if (entryCount < 1) return null;
4775
+ const entryStart = o + 8;
4776
+ if (entryStart + 36 > box.end) return null;
4777
+ return {
4778
+ width: bytes[entryStart + 32] << 8 | bytes[entryStart + 33],
4779
+ height: bytes[entryStart + 34] << 8 | bytes[entryStart + 35]
4780
+ };
4781
+ }
4782
+ function _parseMp4Video(bytes) {
4783
+ const topBoxes = _readMp4Boxes(bytes, 0, bytes.length);
4784
+ const ftyp = _findMp4Box(topBoxes, "ftyp");
4785
+ const moov = _findMp4Box(topBoxes, "moov");
4786
+ if (!moov) return { error: "No moov box found (not a valid or fully-downloaded MP4 file)" };
4787
+ const result = { format: "mp4" };
4788
+ if (ftyp && ftyp.start + 4 <= ftyp.end) result.majorBrand = _videoReadAscii4(bytes, ftyp.start);
4789
+ const moovBoxes = _readMp4Boxes(bytes, moov.start, moov.end);
4790
+ const mvhd = _findMp4Box(moovBoxes, "mvhd");
4791
+ if (mvhd) {
4792
+ const info = _parseMp4Mvhd(bytes, mvhd);
4793
+ if (info && info.timescale > 0) result.durationSeconds = Math.round(info.duration / info.timescale * 1e3) / 1e3;
4794
+ }
4795
+ for (const trak of moovBoxes.filter((b) => b.type === "trak")) {
4796
+ const trakBoxes = _readMp4Boxes(bytes, trak.start, trak.end);
4797
+ const mdia = _findMp4Box(trakBoxes, "mdia");
4798
+ if (!mdia) continue;
4799
+ const mdiaBoxes = _readMp4Boxes(bytes, mdia.start, mdia.end);
4800
+ const hdlr = _findMp4Box(mdiaBoxes, "hdlr");
4801
+ const handlerType = hdlr ? _parseMp4Hdlr(bytes, hdlr) : null;
4802
+ const minf = _findMp4Box(mdiaBoxes, "minf");
4803
+ if (!minf) continue;
4804
+ const stbl = _findMp4Box(_readMp4Boxes(bytes, minf.start, minf.end), "stbl");
4805
+ if (!stbl) continue;
4806
+ const stsd = _findMp4Box(_readMp4Boxes(bytes, stbl.start, stbl.end), "stsd");
4807
+ const codec = stsd ? _parseMp4StsdCodec(bytes, stsd) : null;
4808
+ if (handlerType === "vide") {
4809
+ if (codec) result.videoCodec = codec;
4810
+ const tkhd = _findMp4Box(trakBoxes, "tkhd");
4811
+ const dims = tkhd ? _parseMp4Tkhd(bytes, tkhd) : null;
4812
+ if (dims && dims.width > 0 && dims.height > 0) {
4813
+ result.width = Math.round(dims.width);
4814
+ result.height = Math.round(dims.height);
4815
+ } else if (stsd) {
4816
+ const pixelDims = _parseMp4StsdVideoDims(bytes, stsd);
4817
+ if (pixelDims && pixelDims.width > 0 && pixelDims.height > 0) {
4818
+ result.width = pixelDims.width;
4819
+ result.height = pixelDims.height;
4820
+ }
4821
+ }
4822
+ } else if (handlerType === "soun") {
4823
+ if (codec) result.audioCodec = codec;
4824
+ }
4825
+ }
4826
+ if (result.durationSeconds === void 0 && !result.videoCodec && !result.audioCodec) {
4827
+ return { error: "Could not find any usable track metadata in this MP4 file's moov box" };
4828
+ }
4829
+ return result;
4830
+ }
4831
+ function _ebmlVintLength(firstByte) {
4832
+ if (firstByte === 0) return 0;
4833
+ let mask = 128;
4834
+ let length = 1;
4835
+ while (length <= 8 && (firstByte & mask) === 0) {
4836
+ mask >>= 1;
4837
+ length++;
4838
+ }
4839
+ return length;
4840
+ }
4841
+ function _readEbmlId(bytes, offset) {
4842
+ if (offset >= bytes.length) return null;
4843
+ const length = _ebmlVintLength(bytes[offset]);
4844
+ if (length === 0 || offset + length > bytes.length) return null;
4845
+ let id = 0;
4846
+ for (let i = 0; i < length; i++) id = id * 256 + bytes[offset + i];
4847
+ return { id, length };
4848
+ }
4849
+ function _readEbmlSize(bytes, offset) {
4850
+ if (offset >= bytes.length) return null;
4851
+ const length = _ebmlVintLength(bytes[offset]);
4852
+ if (length === 0 || offset + length > bytes.length) return null;
4853
+ const mask = 255 >> length;
4854
+ let value = bytes[offset] & mask;
4855
+ let allOnes = value === mask;
4856
+ for (let i = 1; i < length; i++) {
4857
+ value = value * 256 + bytes[offset + i];
4858
+ if (bytes[offset + i] !== 255) allOnes = false;
4859
+ }
4860
+ return { value, length, unknown: allOnes };
4861
+ }
4862
+ function _readEbmlUint(bytes, offset, length) {
4863
+ let value = 0;
4864
+ for (let i = 0; i < length; i++) value = value * 256 + bytes[offset + i];
4865
+ return value;
4866
+ }
4867
+ function _readEbmlFloat(bytes, offset, length) {
4868
+ if (offset + length > bytes.length) return 0;
4869
+ const view = new DataView(bytes.buffer, bytes.byteOffset + offset, length);
4870
+ if (length === 4) return view.getFloat32(0, false);
4871
+ if (length === 8) return view.getFloat64(0, false);
4872
+ return 0;
4873
+ }
4874
+ function _ebmlChildren(bytes, start, end) {
4875
+ const children = [];
4876
+ let offset = start;
4877
+ while (offset < end) {
4878
+ const idInfo = _readEbmlId(bytes, offset);
4879
+ if (!idInfo) break;
4880
+ const sizeInfo = _readEbmlSize(bytes, offset + idInfo.length);
4881
+ if (!sizeInfo) break;
4882
+ const dataStart = offset + idInfo.length + sizeInfo.length;
4883
+ const dataEnd = sizeInfo.unknown ? end : Math.min(dataStart + sizeInfo.value, end);
4884
+ children.push({ id: idInfo.id, dataStart, dataEnd });
4885
+ offset = dataEnd;
4886
+ }
4887
+ return children;
4888
+ }
4889
+ var _EBML_ID_SEGMENT = 408125543;
4890
+ var _EBML_ID_INFO = 357149030;
4891
+ var _EBML_ID_TIMECODE_SCALE = 2807729;
4892
+ var _EBML_ID_DURATION = 17545;
4893
+ var _EBML_ID_TRACKS = 374648427;
4894
+ var _EBML_ID_TRACK_ENTRY = 174;
4895
+ var _EBML_ID_TRACK_TYPE = 131;
4896
+ var _EBML_ID_CODEC_ID = 134;
4897
+ var _EBML_ID_VIDEO = 224;
4898
+ var _EBML_ID_PIXEL_WIDTH = 176;
4899
+ var _EBML_ID_PIXEL_HEIGHT = 186;
4900
+ var _EBML_ID_CLUSTER = 524531317;
4901
+ function _parseWebmVideo(bytes) {
4902
+ const top = _ebmlChildren(bytes, 0, bytes.length);
4903
+ const segment = top.find((c) => c.id === _EBML_ID_SEGMENT);
4904
+ if (!segment) return { error: "No Segment element found (not a valid WebM/Matroska file)" };
4905
+ const result = { format: "webm" };
4906
+ let timecodeScale = 1e6;
4907
+ let rawDuration;
4908
+ for (const child of _ebmlChildren(bytes, segment.dataStart, segment.dataEnd)) {
4909
+ if (child.id === _EBML_ID_CLUSTER) break;
4910
+ if (child.id === _EBML_ID_INFO) {
4911
+ for (const f of _ebmlChildren(bytes, child.dataStart, child.dataEnd)) {
4912
+ if (f.id === _EBML_ID_TIMECODE_SCALE) timecodeScale = _readEbmlUint(bytes, f.dataStart, f.dataEnd - f.dataStart) || 1e6;
4913
+ else if (f.id === _EBML_ID_DURATION) rawDuration = _readEbmlFloat(bytes, f.dataStart, f.dataEnd - f.dataStart);
4914
+ }
4915
+ } else if (child.id === _EBML_ID_TRACKS) {
4916
+ for (const entry of _ebmlChildren(bytes, child.dataStart, child.dataEnd)) {
4917
+ if (entry.id !== _EBML_ID_TRACK_ENTRY) continue;
4918
+ let trackType;
4919
+ let codecId;
4920
+ let pixelWidth;
4921
+ let pixelHeight;
4922
+ for (const f of _ebmlChildren(bytes, entry.dataStart, entry.dataEnd)) {
4923
+ if (f.id === _EBML_ID_TRACK_TYPE) trackType = _readEbmlUint(bytes, f.dataStart, f.dataEnd - f.dataStart);
4924
+ else if (f.id === _EBML_ID_CODEC_ID) codecId = Buffer.from(bytes.subarray(f.dataStart, f.dataEnd)).toString("ascii").replace(/\0+$/, "");
4925
+ else if (f.id === _EBML_ID_VIDEO) {
4926
+ for (const v of _ebmlChildren(bytes, f.dataStart, f.dataEnd)) {
4927
+ if (v.id === _EBML_ID_PIXEL_WIDTH) pixelWidth = _readEbmlUint(bytes, v.dataStart, v.dataEnd - v.dataStart);
4928
+ else if (v.id === _EBML_ID_PIXEL_HEIGHT) pixelHeight = _readEbmlUint(bytes, v.dataStart, v.dataEnd - v.dataStart);
4929
+ }
4930
+ }
4931
+ }
4932
+ if (trackType === 1) {
4933
+ if (codecId) result.videoCodec = codecId;
4934
+ if (pixelWidth) result.width = pixelWidth;
4935
+ if (pixelHeight) result.height = pixelHeight;
4936
+ } else if (trackType === 2) {
4937
+ if (codecId) result.audioCodec = codecId;
4938
+ }
4939
+ }
4940
+ }
4941
+ }
4942
+ if (rawDuration !== void 0 && timecodeScale > 0) {
4943
+ result.durationSeconds = Math.round(rawDuration * timecodeScale / 1e9 * 1e3) / 1e3;
4944
+ }
4945
+ if (result.durationSeconds === void 0 && !result.videoCodec && !result.audioCodec) {
4946
+ return { error: "Could not find any usable metadata in this WebM file's Segment element" };
4947
+ }
4948
+ return result;
4949
+ }
4950
+ function _readVideoInfo(bytes) {
4951
+ if (bytes.length < 12) return { error: "File is too small to be a valid video file" };
4952
+ if (_videoReadAscii4(bytes, 4) === "ftyp") return _parseMp4Video(bytes);
4953
+ if (bytes[0] === 26 && bytes[1] === 69 && bytes[2] === 223 && bytes[3] === 163) return _parseWebmVideo(bytes);
4954
+ return { error: 'Not a recognized MP4 or WebM file (missing an "ftyp" box or an EBML header signature)' };
4955
+ }
4956
+ server.tool("read_video_info", "Read duration, resolution, and video/audio codec identifiers from an MP4 (ISO BMFF) or WebM (EBML/Matroska) file's container header. No frame decoding, demuxing, or transcoding is performed.", { video_base64: z.string().describe("Base64-encoded MP4 or WebM file bytes, optionally prefixed with a data: URL scheme") }, async ({ video_base64 }) => {
4957
+ const bytes = new Uint8Array(Buffer.from(video_base64.replace(/^data:.*;base64,/, ""), "base64"));
4958
+ const result = _readVideoInfo(bytes);
4959
+ if ("error" in result) return errText(result);
4960
+ return text(JSON.stringify(result, null, 2));
4961
+ });
4702
4962
  var transport = new StdioServerTransport();
4703
4963
  await server.connect(transport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utilix-tech/mcp",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "MCP server exposing 143 Utilix developer tools to Claude, Cursor, VS Code Copilot, and any MCP-compatible AI assistant.",
5
5
  "author": "Utilix <hello@utilix.tech>",
6
6
  "license": "MIT",