Webear

io.github.asume21由 GitHub 账号 asume21 发布v1.2.4更新于 Oct 24, 2026

Give your AI coding assistant ears — capture, analyze, and describe live audio.

概览

AI 生成的概览

WebEar 让 AI 编程助手捕获并分析网页应用 Web Audio 图输出的实时音频,还可选配视觉、性能、网络、安全与日志感知。

可以做什么
从运行中的网页应用 Web Audio 输出捕获短音频片段,并分析响度、峰值、削波、频谱质心、频段能量、BPM 与时间抖动,或生成对声音的通俗描述。对比两次捕获,标出响度、音色、时序与削波的变化,并给出结构化混音建议或律动评分。通过更完整的 Web Perception 传感器套件,捕获并分析画布/视频画面、性能遥测、网络耗时、安全暴露面与控制台日志。
适用场景
适合 Web Audio、Tone.js、游戏音频与音乐应用开发者,在调试混音、效果或提交间回归时让助手听到并测量应用的实际输出。也适合在 IDE 内检查本地网页应用的视觉、性能、网络与控制台表现。
运行要求
通过 npx 以 stdio 在本地运行,需要 Node.js 18 或更高版本,以及支持 MediaRecorder 的浏览器。需在开发服务器和网页应用中分别加入 Express 中间件与客户端片段,并用 WEBEAR_BASE_URL 指向该服务器。CODEDSWITCH_API_KEY 可选:没有它时本地分析需要 PATH 中有 ffmpeg;有它才解锁完整分析、描述与对比。
安装前请注意
CODEDSWITCH_API_KEY 是密钥,应通过环境变量提供,不要提交到代码库。使用密钥时,捕获的音频会发送给第三方 CodedSwitch 分析 API;无密钥且有 ffmpeg 时分析在本地完成。中间件把捕获保存在内存中,仅供开发使用,生产环境应保持禁用。分析调用会消耗免费额度。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Webear,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

webear

[npm version] [npm downloads] [License: MIT] [MCP Compatible]

Give your AI real senses — hear, see, and feel any web app.

An MCP server + browser SDK that gives AI coding assistants direct sensory access to a live web application. Audio, visuals, performance, network, security, and console — captured from the browser, analyzed in real time, delivered via MCP.

"The beat sounds muddy" → your AI captures 3 seconds, measures the spectral centroid at 580 Hz with 45% energy below 250 Hz, and tells you exactly why.


[AI Web Perception Demo]


What It Does

ToolDescription
capture_audioRecord a short clip (500ms–30s) of what your web app is outputting right now
analyze_audioSignal analysis: RMS, peak dB, clipping, spectral centroid, frequency bands, BPM, timing jitter
describe_audioPlain-English AI description — "the kick is boomy with heavy sub buildup around 80 Hz"
diff_audioCompare two captures and flag what changed — loudness, tone, timing, clipping

How It Works

Browser (Web Audio API)    ↓ MediaRecorder taps the AudioContext output node    ↓ Uploads WebM blob via HTTP POSTExpress Middleware (your dev server)    ↓ Stores captures in memory, dispatches commands via SSEMCP Server (stdio — runs inside your IDE)    ↓ Retrieves captures, sends to CodedSwitch analysis APIAI Coding Assistant    → "Your bass band is 42% of the mix (high), spectral centroid       is 580 Hz (muddy), and timing jitter is 23ms — the scheduler       is drifting under load."

The key difference from every other audio MCP: this taps the Web Audio graph directly, bypassing room acoustics, microphone hardware, and the need to export files.


Quick Start

1. Install

bash
npm install webear

2. Add the Express middleware to your dev server

js
import express from 'express'import { webearMiddleware } from 'webear/middleware'
const app = express()app.use(express.json())
// Mount the audio debug bridge (automatically disabled in production)app.use('/api/webear', webearMiddleware())
app.listen(5000)

3. Add the client snippet to your web app

Option A — auto-detect everything (Tone.js or raw Web Audio)

js
import WebEar from 'webear/client'WebEar.init()

Option B — explicit AudioContext

js
const ctx = new AudioContext()const masterGain = ctx.createGain()masterGain.connect(ctx.destination)
WebEar.init({ audioContext: ctx, outputNode: masterGain })

Option C — Tone.js project

js
import * as Tone from 'tone'WebEar.init({ toneJs: true })

Option D — Three.js WebGL Game

js
import * as THREE from 'three'const listener = new THREE.AudioListener()camera.add(listener)WebEar.init({ tapNode: listener.getInput() })

Option E — plain script tag

html
<script src="node_modules/webear/client-snippet.js"></script><script>WebEar.init()</script>

4. Configure your IDE

Claude Code (.mcp.json in project root):

json
{  "mcpServers": {    "webear": {      "command": "npx",      "args": ["webear"],      "env": {        "WEBEAR_BASE_URL": "http://localhost:5000",        "CODEDSWITCH_API_KEY": "your-key-here"      }    }  }}

Cursor (.cursor/mcp.json):

json
{  "mcpServers": {    "webear": {      "command": "npx",      "args": ["webear"],      "env": {        "WEBEAR_BASE_URL": "http://localhost:5000",        "CODEDSWITCH_API_KEY": "your-key-here"      }    }  }}

Windsurf (mcp_config.json):

json
{  "webear": {    "command": "npx",    "args": ["webear"],    "disabled": false,    "env": {      "WEBEAR_BASE_URL": "http://localhost:5000",      "CODEDSWITCH_API_KEY": "your-key-here"    }  }}

5. Get an API key — optional, and not to start

analyze_audio works with no key and no account. If ffmpeg is on your PATH, it decodes and analyzes the capture on your machine and returns a basic report: duration, loudness, peak level and whether the audio is clipping. Nothing is uploaded. Try the tool before you sign up for anything.

A key unlocks the parts that need more than arithmetic:

No keyWith key
capture_audio✓✓
analyze_audioBasic — duration, loudness, peak, clipping (local)Full — spectral centroid, band energy, crest factor, BPM, timing jitter
describe_audio — what it SOUNDS like—✓
mix_coach — measured + heard—✓
diff_audio — before/after—✓

To get one:

  1. Create a free account at codedswitch.com.
  2. Go to codedswitch.com/developer (also in the account menu as Developer API).
  3. Click Generate API Key — that value is your CODEDSWITCH_API_KEY. Keys start with wbr_.

Free tier: 50 analyses/day. No credit card required.

6. Start your dev server, open your app, play audio, then ask your AI:

"Capture 3 seconds and tell me why the bass sounds muddy."

"Compare the audio before and after my last commit."

"Is there any clipping in the high-frequency range?"


Example Output

analyze_audio

── Audio Analysis Report ──────────────────────────────Duration:          3.02s
── Loudness ─────────────────────────────────────────RMS:               -12.4 dBFSPeak:              -1.2 dBFSDynamic range:     11.2 dBCrest factor:      3.63Clipping:          none
── Tone ──────────────────────────────────────────────Spectral centroid: 2847 HzDC offset:         0.00012 (ok)
── Frequency Bands ───────────────────────────────────Sub  (20-80 Hz):   8.2%Bass (80-250 Hz):  22.1%Mid  (250-2k Hz):  38.4%Hi-mid (2-6k Hz):  21.8%High (6k+ Hz):     9.5%
── Rhythm ────────────────────────────────────────────Estimated BPM:     92Onset count:       12Timing jitter:     4.2 ms std dev
── Summary ───────────────────────────────────────────Loudness: -12.4 dBFS RMS, peak -1.2 dBFS. Tone: balanced (centroid 2847 Hz).Band mix — sub: 8% | bass: 22% | mid: 38% | hi-mid: 22% | high: 10%.Rhythm: estimated 92 BPM, 12 onsets detected. Timing: very tight (< 5 ms jitter).

diff_audio

── Audio Diff: a1b2c3d4… → e5f6g7h8… ──
── Loudness ──────────────────────────────────────────  RMS: -14.2 dBFS → -12.4 dBFS  (+1.8 dBFS)⚠ Peak: -3.1 dBFS → -0.2 dBFS  (+2.9 dBFS)⚠ CLIPPING INTRODUCED — gain staging regression
── Tone ──────────────────────────────────────────────⚠ Spectral centroid: 2847.0 Hz → 1920.0 Hz  (-927.0 Hz)
── Interpretation ────────────────────────────────────A gain bug was introduced that causes clipping.Tonal character changed noticeably — EQ or filter behaviour may have shifted.

Configuration

Environment Variables

VariableDefaultDescription
WEBEAR_BASE_URLhttp://localhost:4000URL of your dev server (where middleware is mounted)
CODEDSWITCH_API_KEY—API key from codedswitch.com — required for analyze_audio and describe_audio
MCP_API_URLhttps://www.codedswitch.comOverride the analysis API base (advanced / self-hosted)

Middleware Options

js
webearMiddleware({  maxCaptures: 50,       // Max captures in memory (default: 50)  maxAgeMins: 10,        // Auto-evict after N minutes (default: 10)  maxUploadBytes: 50e6,  // Max upload size (default: 50MB)  devOnly: true,         // Disable in production (default: true)})

Client Options

js
WebEar.init({  audioContext: myCtx,             // Your AudioContext instance  outputNode: myGainNode,          // The node to tap (defaults to destination)  toneJs: true,                    // Auto-detect Tone.js context  bridgeBase: '/api/webear',  // Override API path  devOnly: true,                   // Only init outside of production (default: true)})

Requirements

  • Node.js >= 18
  • A browser that supports MediaRecorder (Chrome, Firefox, Edge, Safari 14+)
  • A CODEDSWITCH_API_KEY for analysis (free at codedswitch.com)

Who Is This For?

  • Web Audio / Tone.js developers — debug beats, synths, effects, and mixing without leaving your IDE
  • Game audio developers — verify sound effects, spatial audio, and mixing in real-time
  • Music app builders — catch regressions between code changes with diff_audio
  • Podcast / streaming apps — validate audio quality, levels, and encoding
  • Anyone whose app makes sound — if it has a Web Audio graph, your AI can now hear it

Why Not Just Use the Microphone?

Microphone MCPs capture room sound — your fan noise, chair creaks, and room reverb are all in the recording. webear taps the Web Audio API before it hits the DAC, giving you a clean digital signal with no room artifacts.


Web Perception — Full Sensor Suite

WebEar started as audio-only. Web Perception expands it to 6 senses:

SensorWhat it perceives
WebEarAudio — mix quality, rhythm, instruments, clipping
WebEyeVisual — canvas, UI layout, animations, screenshots
WebSensePerformance — frame rate, memory, audio latency
WebNerveNetwork — API latencies, connection quality, storage
WebShieldSecurity — cookies, storage exposure, CSP, framing
WebLogConsole — logs, warnings, errors, uncaught exceptions

Install the full browser SDK

js
import { WebPerception } from 'webear/perception'
WebPerception.init({  apiKey: 'wbr_YOUR_API_KEY',  relayUrl: 'https://www.codedswitch.com',  sensors: ['ear', 'eye', 'sense', 'nerve', 'shield', 'log'],})

Or use a single sensor:

js
import { WebEar } from 'webear/perception'
WebEar.init({  apiKey: 'wbr_YOUR_API_KEY',  ear: { audioContext: myCtx, audioNode: masterGain },})

Connect via MCP (hosted relay — no local server required)

json
{  "mcpServers": {    "webear": {      "url": "https://www.codedswitch.com/api/webear/mcp/sse",      "headers": {        "Authorization": "Bearer wbr_YOUR_API_KEY"      }    }  }}

Available MCP Tools

SensorToolCreditsDescription
Earcapture_audioFreeRecord live tab audio
Earanalyze_audio1BPM, loudness, frequency bands, clipping, dynamic range
Eardescribe_audio2AI plain-English description — instruments, genre, mood, mix notes
Eardiff_audio1Compare two captures — loudness, tone, timing deltas
Eargroove_score2Grid alignment, swing factor, consistency (0–100%)
Earcapture_and_analyze1Capture + analysis in one call
Earmix_coach3Structured mixing feedback
Eyecapture_videoFreeRecord canvas/video from the tab
Eyedescribe_video2AI visual description — layout, colors, bugs
Eyediff_visuals2Compare two visual captures
Sensecapture_telemetryFreeFPS, memory, layout shifts, audio latency
Senseanalyze_telemetry1Frame drops, memory pressure, audio underruns
Nervecapture_nerveFreeAPI timings, connection quality, storage size
Nerveanalyze_nerve1Slow APIs, connection quality, storage bloat
Shieldcapture_shieldFreeCookies, CSP, storage exposure, framing
Shieldanalyze_shield1CORS issues, non-HttpOnly cookies, missing CSP
Logcapture_logsFreeConsole output + uncaught exceptions
Loganalyze_logs1Error patterns, stack traces, repeated warnings

Get an API Key

  1. Create a free account at codedswitch.com.
  2. Open codedswitch.com/developer — also linked as Developer API in the account menu.
  3. Click Generate API Key and copy it. Keys start with wbr_.

Free tier: 50 analyses/day, no credit card required.


Changelog

2.0.1

  • Fixed the getting-started path for API keys. The previous instruction ("Settings → WebEar") was wrong — there is no WebEar section under Settings. Keys live at codedswitch.com/developer (linked as Developer API in the account menu). Both the Quick Start and the Web Perception sections now point to the correct place.
  • The SDK's "missing API key" console error now links straight to the key page.

Contributing

See CONTRIBUTING.md.

License

MIT — see LICENSE

Author

Built by @asume21 — CodedSwitch

来源:README.md,提交 fa1ce2e

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.2.4最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分