Logo Emby.MCP

Emby.MCP

Cộng đồng
angeltek

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

Nhà phát hànhangeltek
Kho mãEmby.MCP
Ngôn ngữPython
Bản fork
5
Sao
10
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépGPL-3.0
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    Emby.MCP cung cấp các chức năng MCP cho các ứng dụng khách AI và tác nhân AI tương thích.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Mẫu cấu hình có thể sao chép ngay

    Dùng các đoạn cấu hình mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Mức độ quan tâm của cộng đồng đến kho mã

    10 sao và 5 bản fork từ kho mã được liên kết.

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/.

Cài đặt

TypingMind
Yêu cầu:

Node.js 18+

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

Dùng MCP Emby.MCP với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối Emby.MCP, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Thiết lập trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Thiết lập trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh thiết lập trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Để tiến trình tiếp tục chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Để tiến trình tiếp tục chạy trong cửa sổ Terminal khi bạn dùng các công cụ MCP.
3

Thêm Emby.MCP làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của Emby.MCP.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "angeltek-emby-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "emby-mcp"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của Emby.MCP, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của Emby.MCP.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện trên TypingMind dùng các công cụ MCP đã bật với mô hình AI đã chọn
Bạn có thể dùng Emby.MCP giúp tôi làm việc này không?
Emby.MCP
Được. Tôi đọc rồi.
Đây là kết quả tôi tìm được bằng Emby.MCP.

Câu hỏi thường gặp

Máy chủ MCP Emby.MCP dùng để làm gì?

Emby.MCP là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP Emby.MCP với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng Emby.MCP với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP Emby.MCP với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối Emby.MCP, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP Emby.MCP với TypingMind?

Emby.MCP hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP Emby.MCP cung cấp những công cụ nào trong TypingMind?

Emby.MCP cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP Emby.MCP không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu Emby.MCP yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇