Emby.MCP 标志

Emby.MCP

社区
angeltek

Model Context Protocol (MCP) server that connects an Emby media server to an AI client such as Claude Desktop.

发布者angeltek
代码仓库Emby.MCP
语言Python
复刻数
5
星标数
10
可用工具
0
传输类型stdio
分类
许可协议GPL-3.0
链接
  • 将工具接入 AI 工作流

    Emby.MCP 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 10 个星标和 5 个复刻。

Emby.MCP

Model Context Protocol (MCP) server that connects an Emby media server to an AI client such as Claude Desktop, creating a kind of Amazon Alexa (tm) for any MCP compliant LLM using your own media collection. A personal MCP and Python learning exercise, inspired into action by hearing Yoko Li talk about her Morse Code MCP server.

Note, this is an independent project with no affiliation to, or endorsement by, Emby LLC.

Contents

Features | Requirements | Installation | Usage | Under The Hood | Also See | License

Features

A minimum viable project that allows an LLM to do the following via MCP tools:

  • Log on to & log out of an Emby media server;
  • Retrieve a list of media libraries;
  • Select a specified library;
  • Retrieve a list of genres used in that library;
  • Search for items in that library by genre, item title, album name, release year, and lyrics, chunking the response as needed;
  • Retrieve playlists, create new playlists, add items to playlists & re-order them, and share playlists with other Emby users;
  • Retrieve a list of accessible media players known to Emby;
  • Retrieve the current play queue of a specified media player;
  • Control the playing, pausing, seeking, etc of a specified media player, including transferring the queue to another player.

Requirements

  • Python v3.13 or higher
  • The uv package/project manager
  • The MCP Server SDK for Python v1.94 or higher
  • The Emby client SDK for Python v4.9.0.33, with hotfix patches (see below).
  • A working Emby Media Server with a library of media files, either local or accessible via a network.
  • An MCP-compatible LLM/AI client. Emby.MCP was developed using Claude Desktop, however at time of writing more than 60 other clients were listed in the Feature Support Matrix - pick one that supports Tools.
  • An LLM subscription plan that supports MCP (this may require payment).

Installation

The following instructions are for a clean installation on Windows 11 Pro - adjust for your own platform and needs.

Install Python | Install Emby.MCP | Install Patches | Login Config | Basic Checks | Configure LLM

Install Python

  • Install latest Python. Customise the install: Optional Features = select all | Advanced Options = install for all, associate files, create shortcuts, add to environment, precompile.
  • From a Powershell terminal, run:
pip install uv
  • Add uv to the path via Windows Settings > System > About > Advanced > [control panel opens] > Environment Variables > [double-click on Path in the User section at top] > [window opens] > New. Paste in the following (change "313" to the Python version that was installed above, ignoring the 3rd ".x" part): %USERPROFILE%\AppData\Roaming\Python\Python313\Scripts

Install Emby.MCP

  • Create empty folder \path\to\Emby.MCP somewhere on your computer.
  • Download the Emby.MCP files from GitHub into this folder, overwriting any existing files if you are performing an upgrade.
  • Install all dependencies by running the following from a Powershell terminal:
cd "\path\to\Emby.MCP"
uv sync --link-mode=copy

Install Hotfix Patches

At every Python virtual environment sync (like the step above) you will need to patch the Emby client SDK until these fix on github have been incorporated into Emby's official release.

  • From a Powershell terminal, run:
cd \path\to\Emby.MCP
copy "hotfixes\emby\configuration.py" ".venv\Lib\site-packages\emby_client"
copy "hotfixes\emby\user_service_api.py" ".venv\Lib\site-packages\emby_client\api"

Login Configuration

The Emby login credentials must be stored in file ".env" which you must create in \path\to\Emby.MCP (for security reasons it is NOT included in the git repo).

  • Paste the following into the new ".env" file, amending for your own server as required:
#------------
# Replace with your Emby server login details
EMBY_SERVER_URL = "http://localhost:8096"
EMBY_USERNAME = "user"
EMBY_PASSWORD = "pass"
# Set to False to NOT verify the server's SSL certificate (eg if self-signed). Defaults to True.
EMBY_VERIFY_SSL = True
# Each LLM has an upper limit on the amount of data it can ingest per tool call.
# Set the max number of items returned per chunk by search tools (or 0 for no limit).
# Items with rich metadata can average around 1,800 bytes each in JSON UTF8 format.
LLM_MAX_ITEMS = 100
#------------
  • You may want to create a dedicated Emby user for Emby.MCP so that you can limit what it can do and what it can see.

Basic Checks

At this point the script should be able to run some startup checks by accessing your Emby server.

  • From a Powershell terminal, run:
cd "\path\to\Emby.MCP"
uv run emby_mcp_server.py
  • This should produce an output similar to this (depending on your Emby set up):
Emby.MCP Copyright (C) 2025 Dominic Search <code@angeltek.co.uk>
This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions; see LICENSE.txt for details.

Running startup checks...
Logon to media server was successful.
Found 3 available libraries
[
  {
    "name": "Music",
    "type": "music",
    "id": "23023"
  },
  {
    "name": "Playlists",
    "type": "playlists",
    "id": "23033"
  },
  {
    "name": "Movies",
    "type": "movies",
    "id": "23042"
  },
]
Logout from media server was successful
Startup checks have completed.

Running Emby.MCP in standalone mode, press CTRL-C to exit.
  • If this is successful, press Control-C or close the Powershell terminal to exit the script.

Configure Your LLM MCP Client

  • Add the Emby.MCP integration to the MCP SDK by running the following from a Powershell terminal:
cd \path\to\Emby.MCP
uv run mcp install --name "Emby" --with "embyclient" emby_mcp_server.py
  • Use the instructions below for your choice of client, If you use a client that is not listed here, then you will need to adapt these instructions yourself.

Claude Desktop

Claude is a good choice as a general-purpose LLM chatbot that works well with Emby.MCP, but requires payment.

  • Install the latest Claude Desktop app on the same machine that you installed Python.
  • You will need to have at least a Pro subscription - the free plan does not support MCP, unfortunately :-|
  • Edit file %USERPROFILE%\AppData\Roaming\Claude\claude_desktop_config.json (Clicking through Claude Desktop > File menu > Settings > Developer > Edit Config will open File Explorer on this file - edit it in Notepad or whatever). Modify so that it looks something like this, noting that on Windows path separators must be escaped as \\ :
{
  "mcpServers": {
    "Emby": {
      "command": "uv.exe",
      "args": [
        "run",
        "--directory",
        "C:\\path\\to\\Emby.MCP",
        "--with",
        "embyclient",
        "--with",
        "mcp[cli]",
        "mcp",
        "run",
        "emby_mcp_server.py"
      ]
    }
  }
}
  • Ensure Claude Desktop is fully shutdown (File menu > Exit) and then (re)start it.
  • Note: if you start Claude Desktop at any time when your Emby server is unavailable then you will get an error message. This is especially the case if Claude is set to "Run on Startup" and your Emby server is installed on the same computer (Claude may start before Emby). Claude will continue to function correctly without Emby.MCP - just restart Claude when the Emby server becomes available.
  • If you get an error message on first-time start up for any other reason, double-check the path in claude_desktop_config.json above, especially that it uses \\ not single \ in the directory path.
  • Emby.MCP sends messages about serious errors to the standard error output which Claude writes to its log files, so read through %USERPROFILE%\AppData\Roaming\Claude\logs\mcp-server-Emby.log and %USERPROFILE%\AppData\Roaming\Claude\logs\mcp.log looking for clues. This can be frustrating!

Microsoft Visual Studio Code

Visual Studio Code is a good choice for developers - it integrates with MS Copilot and works reasonably well with Emby.MCP

  • Install the latest VS Code app on the same machine that you installed Python. You need at least v1.102 for full MCP support.
  • You will need to have a Copilot enabled github account, along with the relevant VS Code extentions installed & working. You do not need a pay-for Copilot Pro subscription - the free plan supports MCP, however you may run into monthly usage limits.
  • Use the official documentation to Add an MCP Server, perhaps via your user configuration
  • Modify the mcp.json file so that it looks something like this, noting that on Windows path separators must be escaped as \\ :
{
	"servers": {
		"Emby": {
			"command": "uv.exe",
			"args": [
				"run",
				"--directory",
				"C:\\path\\to\\Emby.MCP",
				"--with",
				"embyclient",
				"--with",
				"mcp[cli]",
				"mcp",
				"run",
				"emby_mcp_server.py"
			]
		}
	}
}

Usage

Allow The Client to Use Tools

The first time an MCP client like Claude Desktop or VS Code tries to use a new MCP tool, a pop-up will appear asking for permission to use it. To avoid being asked each time, press or select Allow always.

Starting a Conversation:

It's a good idea to select an Emby library at the start of a conversation in order to narrow search results and reduce the amount of return data that the LLM has to deal with (that said, you can search across multiple libraries if you wish). E.g., from Claude:

list emby libraries

I'll help you explore your Emby library. Let me start by checking what libraries are available on your Emby server.

Your Emby server has several libraries available:

  • Music - Main music library

  • Playlists - Your saved playlists

  • Movies - Movie collection

  • BBC Sounds - BBC audio content

select bbc library

Perfect! I've selected the BBC Sounds library.

You can now search, browse, or explore content within the BBC Sounds library. What would you like to do next?

Instructing Your LLM

On startup, the MCP client receives the list of tools from Emby.MCP (all functions that have @mcp.tool() immediately prior to their def line), along with the parameter names and the content of the docstring.

The docstring is a natural language description of the tool, its parameters and its output. From this, the LLM gains an understanding of the capabilities it has at hand, and is quite good at reasoning which tools are required for the instructions that you give it. But it isn't perfect, so:

  • Be brief and specific to reduce LLM confusion.
  • Start a conversation by mentioning Emby as a hint that Emby.MCP tools should be used.
  • If you want to search for audio or video based on a phrase in the lyrics or description then be explicit about this in your instructions, otherwise the LLM may only search on Title or Artist.
  • LLMs attempt not to ingest large amounts of data, such as from a vague search of a large library. Emby.MCP works around this by returning results in bite-sized chunks. Sometimes even this is insufficient, so your instructions may need get creatively persuasive.

Example Transcript

My Emby server contains a lot of BBC Radio audio drama files that have rich mp3/mp4 metadata, including a long description with full cast list in the Lyrics field. This is good material for demonstrating Emby.MCP... see the separate file Example Claude Transcript.md

Under The Hood

The Emby.MCP code is split over three files. emby_mcp_server.py contains all of the MCP related tool functions. In normal use, MCP does not require there be a classic 'main' function to call (although it is used here for testing purposes). Instead, the MCP Server SDK parses for functions declared as @mcp.tool() and offers these to the MCP client for direct calling.

At client start-up some preliminaries are executed, which includes instantiating FastMCP with 'lifespan' function app_lifespan. This is async code that logs into the Emby server, initialises some updateable 'context' storage (akin to a global variable), and then waits until either the client exits (causing app_lifespan to log out of Emby), or is prodded by other functions to yield its storage (tool functions can write as well as read the context storage).

The MCP tool functions are mostly thin wrappers to functions within lib_emby_functions.py where the heavy lifting takes place. These wrappers are written with LLM comprehension in mind, hence the rather long-form names for functions, parameters, and docstrings (remember that the MCP SDK passes all this to the LLM so that it gains a detailed understanding of the tools). They only return strings - either success/error messages or JSON formatted data.

The exception is search_for_item() and retrieve_next_search_chunk() which attempt to coax the LLM into accepting more data that it really wants to by chunking the return into bite-size pieces (defined by the LLM_MAX_ITEMS variable in the .env file).

The functions in lib_emby_functions.py use Emby's official Client SDK, which does a good job of presenting the server's REST API as Python objects. However it has a few minor bugs that, unpatched, prevent Emby.MCP from working correctly (hence the need for the hotfixes given in installation instructions above). It should be noted that Emby's REST API documentation makes heavy use of CamelCaseNames, whereas the SDK mostly uses lower_case_delinated_names, so a good read-through of the SDK code files is necessary to figure out how to name things correctly.

File lib_emby_debugging.py contains some rudimentary interactive testing of the lib_emby_functions.py functions. They are not full unit tests, but hey, there is only so much effort I wanted to expend in this round of developing a personal project. To activate them, set MY_DEBUG=True at top of emby_mcp_server.py, then interactively run that script (not lib_emby_debugging.py).

The tests write to standard output so that it can be redirected to a file to capture full data that the interactive terminal may otherwise truncate. Prompts & errors messages are sent to standard error so that interaction is still possible during redirection. Enable the different test blocks in lib_emby_debugging.py by setting if True: instead of if False: at their start.

To debug the MCP tools, either install the interactive client included in the SDK, which requires you have a working Node.js environment. Or get the LLM client to perform tests for you, which may mean wading through LLM log files when things break badly (Emby.MCP sends messages about serious problems to standard error, which some MCP clients will obligingly write to log files).

Also See

License

Copyright (C) 2025 Dominic Search code@angeltek.co.uk

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

安装

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "angeltek-emby-mcp": {
      "command": "",
      "args": []
    }
  }
}

将 Emby.MCP MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 Emby.MCP 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请勿关闭终端窗口或停止其中的连接器进程。
3

将 Emby.MCP 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 Emby.MCP MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "angeltek-emby-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "emby-mcp"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 Emby.MCP MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 Emby.MCP MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Emby.MCP 帮我完成这项任务吗?
Emby.MCP
当然,我看过了。
以下是我使用 Emby.MCP 得到的结果。

常见问题

Emby.MCP MCP 服务器有什么用途?

Emby.MCP 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 Emby.MCP MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您无需为每个模型单独配置 MCP 服务器,就能在 Claude、ChatGPT、Gemini 或您在 TypingMind 中配置的其他 AI 模型中使用 Emby.MCP。

为什么在 TypingMind 中使用 Emby.MCP MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是最出色的大语言模型聊天前端之一。连接 Emby.MCP 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 Emby.MCP MCP 连接到 TypingMind?

Emby.MCP 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

Emby.MCP MCP 在 TypingMind 中提供哪些工具?

Emby.MCP 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 Emby.MCP MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行选择模型提供商,并自行管理 API 密钥、提示词和 MCP 配置。如果 Emby.MCP 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇