@cesteral/linkedin-mcp 1.0.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.
Files changed (259) hide show
  1. package/LICENSE.md +201 -0
  2. package/README.md +304 -0
  3. package/dist/auth/index.d.ts +3 -0
  4. package/dist/auth/index.d.ts.map +1 -0
  5. package/dist/auth/index.js +3 -0
  6. package/dist/auth/index.js.map +1 -0
  7. package/dist/auth/linkedin-auth-adapter.d.ts +38 -0
  8. package/dist/auth/linkedin-auth-adapter.d.ts.map +1 -0
  9. package/dist/auth/linkedin-auth-adapter.js +110 -0
  10. package/dist/auth/linkedin-auth-adapter.js.map +1 -0
  11. package/dist/auth/linkedin-auth-strategy.d.ts +14 -0
  12. package/dist/auth/linkedin-auth-strategy.d.ts.map +1 -0
  13. package/dist/auth/linkedin-auth-strategy.js +50 -0
  14. package/dist/auth/linkedin-auth-strategy.js.map +1 -0
  15. package/dist/config/index.d.ts +100 -0
  16. package/dist/config/index.d.ts.map +1 -0
  17. package/dist/config/index.js +37 -0
  18. package/dist/config/index.js.map +1 -0
  19. package/dist/index.d.ts +3 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +40 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/mcp-server/prompts/definitions/analytics-reporting-workflow.prompt.d.ts +4 -0
  24. package/dist/mcp-server/prompts/definitions/analytics-reporting-workflow.prompt.d.ts.map +1 -0
  25. package/dist/mcp-server/prompts/definitions/analytics-reporting-workflow.prompt.js +108 -0
  26. package/dist/mcp-server/prompts/definitions/analytics-reporting-workflow.prompt.js.map +1 -0
  27. package/dist/mcp-server/prompts/definitions/bulk-operations-workflow.prompt.d.ts +4 -0
  28. package/dist/mcp-server/prompts/definitions/bulk-operations-workflow.prompt.d.ts.map +1 -0
  29. package/dist/mcp-server/prompts/definitions/bulk-operations-workflow.prompt.js +177 -0
  30. package/dist/mcp-server/prompts/definitions/bulk-operations-workflow.prompt.js.map +1 -0
  31. package/dist/mcp-server/prompts/definitions/campaign-setup-workflow.prompt.d.ts +4 -0
  32. package/dist/mcp-server/prompts/definitions/campaign-setup-workflow.prompt.d.ts.map +1 -0
  33. package/dist/mcp-server/prompts/definitions/campaign-setup-workflow.prompt.js +171 -0
  34. package/dist/mcp-server/prompts/definitions/campaign-setup-workflow.prompt.js.map +1 -0
  35. package/dist/mcp-server/prompts/definitions/creative-upload-workflow.prompt.d.ts +4 -0
  36. package/dist/mcp-server/prompts/definitions/creative-upload-workflow.prompt.d.ts.map +1 -0
  37. package/dist/mcp-server/prompts/definitions/creative-upload-workflow.prompt.js +109 -0
  38. package/dist/mcp-server/prompts/definitions/creative-upload-workflow.prompt.js.map +1 -0
  39. package/dist/mcp-server/prompts/definitions/cross-platform-campaign-setup.prompt.d.ts +4 -0
  40. package/dist/mcp-server/prompts/definitions/cross-platform-campaign-setup.prompt.d.ts.map +1 -0
  41. package/dist/mcp-server/prompts/definitions/cross-platform-campaign-setup.prompt.js +299 -0
  42. package/dist/mcp-server/prompts/definitions/cross-platform-campaign-setup.prompt.js.map +1 -0
  43. package/dist/mcp-server/prompts/definitions/cross-platform-performance.prompt.d.ts +4 -0
  44. package/dist/mcp-server/prompts/definitions/cross-platform-performance.prompt.d.ts.map +1 -0
  45. package/dist/mcp-server/prompts/definitions/cross-platform-performance.prompt.js +170 -0
  46. package/dist/mcp-server/prompts/definitions/cross-platform-performance.prompt.js.map +1 -0
  47. package/dist/mcp-server/prompts/definitions/entity-duplication-workflow.prompt.d.ts +4 -0
  48. package/dist/mcp-server/prompts/definitions/entity-duplication-workflow.prompt.d.ts.map +1 -0
  49. package/dist/mcp-server/prompts/definitions/entity-duplication-workflow.prompt.js +213 -0
  50. package/dist/mcp-server/prompts/definitions/entity-duplication-workflow.prompt.js.map +1 -0
  51. package/dist/mcp-server/prompts/definitions/entity-update-workflow.prompt.d.ts +4 -0
  52. package/dist/mcp-server/prompts/definitions/entity-update-workflow.prompt.d.ts.map +1 -0
  53. package/dist/mcp-server/prompts/definitions/entity-update-workflow.prompt.js +151 -0
  54. package/dist/mcp-server/prompts/definitions/entity-update-workflow.prompt.js.map +1 -0
  55. package/dist/mcp-server/prompts/definitions/targeting-discovery-workflow.prompt.d.ts +4 -0
  56. package/dist/mcp-server/prompts/definitions/targeting-discovery-workflow.prompt.d.ts.map +1 -0
  57. package/dist/mcp-server/prompts/definitions/targeting-discovery-workflow.prompt.js +217 -0
  58. package/dist/mcp-server/prompts/definitions/targeting-discovery-workflow.prompt.js.map +1 -0
  59. package/dist/mcp-server/prompts/definitions/tool-schema-exploration.prompt.d.ts +4 -0
  60. package/dist/mcp-server/prompts/definitions/tool-schema-exploration.prompt.d.ts.map +1 -0
  61. package/dist/mcp-server/prompts/definitions/tool-schema-exploration.prompt.js +98 -0
  62. package/dist/mcp-server/prompts/definitions/tool-schema-exploration.prompt.js.map +1 -0
  63. package/dist/mcp-server/prompts/definitions/troubleshoot-entity.prompt.d.ts +4 -0
  64. package/dist/mcp-server/prompts/definitions/troubleshoot-entity.prompt.d.ts.map +1 -0
  65. package/dist/mcp-server/prompts/definitions/troubleshoot-entity.prompt.js +91 -0
  66. package/dist/mcp-server/prompts/definitions/troubleshoot-entity.prompt.js.map +1 -0
  67. package/dist/mcp-server/prompts/index.d.ts +9 -0
  68. package/dist/mcp-server/prompts/index.d.ts.map +1 -0
  69. package/dist/mcp-server/prompts/index.js +97 -0
  70. package/dist/mcp-server/prompts/index.js.map +1 -0
  71. package/dist/mcp-server/resources/definitions/analytics-reference.resource.d.ts +3 -0
  72. package/dist/mcp-server/resources/definitions/analytics-reference.resource.d.ts.map +1 -0
  73. package/dist/mcp-server/resources/definitions/analytics-reference.resource.js +162 -0
  74. package/dist/mcp-server/resources/definitions/analytics-reference.resource.js.map +1 -0
  75. package/dist/mcp-server/resources/definitions/entity-examples.resource.d.ts +4 -0
  76. package/dist/mcp-server/resources/definitions/entity-examples.resource.d.ts.map +1 -0
  77. package/dist/mcp-server/resources/definitions/entity-examples.resource.js +164 -0
  78. package/dist/mcp-server/resources/definitions/entity-examples.resource.js.map +1 -0
  79. package/dist/mcp-server/resources/definitions/entity-hierarchy.resource.d.ts +3 -0
  80. package/dist/mcp-server/resources/definitions/entity-hierarchy.resource.d.ts.map +1 -0
  81. package/dist/mcp-server/resources/definitions/entity-hierarchy.resource.js +144 -0
  82. package/dist/mcp-server/resources/definitions/entity-hierarchy.resource.js.map +1 -0
  83. package/dist/mcp-server/resources/definitions/entity-schemas.resource.d.ts +4 -0
  84. package/dist/mcp-server/resources/definitions/entity-schemas.resource.d.ts.map +1 -0
  85. package/dist/mcp-server/resources/definitions/entity-schemas.resource.js +127 -0
  86. package/dist/mcp-server/resources/definitions/entity-schemas.resource.js.map +1 -0
  87. package/dist/mcp-server/resources/definitions/index.d.ts +8 -0
  88. package/dist/mcp-server/resources/definitions/index.d.ts.map +1 -0
  89. package/dist/mcp-server/resources/definitions/index.js +54 -0
  90. package/dist/mcp-server/resources/definitions/index.js.map +1 -0
  91. package/dist/mcp-server/resources/definitions/targeting-reference.resource.d.ts +3 -0
  92. package/dist/mcp-server/resources/definitions/targeting-reference.resource.d.ts.map +1 -0
  93. package/dist/mcp-server/resources/definitions/targeting-reference.resource.js +122 -0
  94. package/dist/mcp-server/resources/definitions/targeting-reference.resource.js.map +1 -0
  95. package/dist/mcp-server/resources/index.d.ts +3 -0
  96. package/dist/mcp-server/resources/index.d.ts.map +1 -0
  97. package/dist/mcp-server/resources/index.js +2 -0
  98. package/dist/mcp-server/resources/index.js.map +1 -0
  99. package/dist/mcp-server/resources/types.d.ts +8 -0
  100. package/dist/mcp-server/resources/types.d.ts.map +1 -0
  101. package/dist/mcp-server/resources/types.js +2 -0
  102. package/dist/mcp-server/resources/types.js.map +1 -0
  103. package/dist/mcp-server/server.d.ts +5 -0
  104. package/dist/mcp-server/server.d.ts.map +1 -0
  105. package/dist/mcp-server/server.js +128 -0
  106. package/dist/mcp-server/server.js.map +1 -0
  107. package/dist/mcp-server/tools/definitions/adjust-bids.tool.d.ts +213 -0
  108. package/dist/mcp-server/tools/definitions/adjust-bids.tool.d.ts.map +1 -0
  109. package/dist/mcp-server/tools/definitions/adjust-bids.tool.js +174 -0
  110. package/dist/mcp-server/tools/definitions/adjust-bids.tool.js.map +1 -0
  111. package/dist/mcp-server/tools/definitions/bulk-create-entities.tool.d.ts +128 -0
  112. package/dist/mcp-server/tools/definitions/bulk-create-entities.tool.d.ts.map +1 -0
  113. package/dist/mcp-server/tools/definitions/bulk-create-entities.tool.js +95 -0
  114. package/dist/mcp-server/tools/definitions/bulk-create-entities.tool.js.map +1 -0
  115. package/dist/mcp-server/tools/definitions/bulk-update-entities.tool.d.ts +183 -0
  116. package/dist/mcp-server/tools/definitions/bulk-update-entities.tool.d.ts.map +1 -0
  117. package/dist/mcp-server/tools/definitions/bulk-update-entities.tool.js +122 -0
  118. package/dist/mcp-server/tools/definitions/bulk-update-entities.tool.js.map +1 -0
  119. package/dist/mcp-server/tools/definitions/bulk-update-status.tool.d.ts +140 -0
  120. package/dist/mcp-server/tools/definitions/bulk-update-status.tool.d.ts.map +1 -0
  121. package/dist/mcp-server/tools/definitions/bulk-update-status.tool.js +109 -0
  122. package/dist/mcp-server/tools/definitions/bulk-update-status.tool.js.map +1 -0
  123. package/dist/mcp-server/tools/definitions/create-entity.tool.d.ts +117 -0
  124. package/dist/mcp-server/tools/definitions/create-entity.tool.d.ts.map +1 -0
  125. package/dist/mcp-server/tools/definitions/create-entity.tool.js +98 -0
  126. package/dist/mcp-server/tools/definitions/create-entity.tool.js.map +1 -0
  127. package/dist/mcp-server/tools/definitions/delete-entity.tool.d.ts +93 -0
  128. package/dist/mcp-server/tools/definitions/delete-entity.tool.d.ts.map +1 -0
  129. package/dist/mcp-server/tools/definitions/delete-entity.tool.js +100 -0
  130. package/dist/mcp-server/tools/definitions/delete-entity.tool.js.map +1 -0
  131. package/dist/mcp-server/tools/definitions/duplicate-entity.tool.d.ts +95 -0
  132. package/dist/mcp-server/tools/definitions/duplicate-entity.tool.d.ts.map +1 -0
  133. package/dist/mcp-server/tools/definitions/duplicate-entity.tool.js +89 -0
  134. package/dist/mcp-server/tools/definitions/duplicate-entity.tool.js.map +1 -0
  135. package/dist/mcp-server/tools/definitions/get-ad-preview.tool.d.ts +75 -0
  136. package/dist/mcp-server/tools/definitions/get-ad-preview.tool.d.ts.map +1 -0
  137. package/dist/mcp-server/tools/definitions/get-ad-preview.tool.js +68 -0
  138. package/dist/mcp-server/tools/definitions/get-ad-preview.tool.js.map +1 -0
  139. package/dist/mcp-server/tools/definitions/get-ad-previews.tool.d.ts +75 -0
  140. package/dist/mcp-server/tools/definitions/get-ad-previews.tool.d.ts.map +1 -0
  141. package/dist/mcp-server/tools/definitions/get-ad-previews.tool.js +71 -0
  142. package/dist/mcp-server/tools/definitions/get-ad-previews.tool.js.map +1 -0
  143. package/dist/mcp-server/tools/definitions/get-analytics-breakdowns.tool.d.ts +223 -0
  144. package/dist/mcp-server/tools/definitions/get-analytics-breakdowns.tool.d.ts.map +1 -0
  145. package/dist/mcp-server/tools/definitions/get-analytics-breakdowns.tool.js +152 -0
  146. package/dist/mcp-server/tools/definitions/get-analytics-breakdowns.tool.js.map +1 -0
  147. package/dist/mcp-server/tools/definitions/get-analytics.tool.d.ts +325 -0
  148. package/dist/mcp-server/tools/definitions/get-analytics.tool.d.ts.map +1 -0
  149. package/dist/mcp-server/tools/definitions/get-analytics.tool.js +154 -0
  150. package/dist/mcp-server/tools/definitions/get-analytics.tool.js.map +1 -0
  151. package/dist/mcp-server/tools/definitions/get-delivery-forecast.tool.d.ts +95 -0
  152. package/dist/mcp-server/tools/definitions/get-delivery-forecast.tool.d.ts.map +1 -0
  153. package/dist/mcp-server/tools/definitions/get-delivery-forecast.tool.js +90 -0
  154. package/dist/mcp-server/tools/definitions/get-delivery-forecast.tool.js.map +1 -0
  155. package/dist/mcp-server/tools/definitions/get-entity.tool.d.ts +75 -0
  156. package/dist/mcp-server/tools/definitions/get-entity.tool.d.ts.map +1 -0
  157. package/dist/mcp-server/tools/definitions/get-entity.tool.js +75 -0
  158. package/dist/mcp-server/tools/definitions/get-entity.tool.js.map +1 -0
  159. package/dist/mcp-server/tools/definitions/get-targeting-options.tool.d.ts +81 -0
  160. package/dist/mcp-server/tools/definitions/get-targeting-options.tool.d.ts.map +1 -0
  161. package/dist/mcp-server/tools/definitions/get-targeting-options.tool.js +76 -0
  162. package/dist/mcp-server/tools/definitions/get-targeting-options.tool.js.map +1 -0
  163. package/dist/mcp-server/tools/definitions/index.d.ts +23 -0
  164. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
  165. package/dist/mcp-server/tools/definitions/index.js +69 -0
  166. package/dist/mcp-server/tools/definitions/index.js.map +1 -0
  167. package/dist/mcp-server/tools/definitions/list-ad-accounts.tool.d.ts +141 -0
  168. package/dist/mcp-server/tools/definitions/list-ad-accounts.tool.d.ts.map +1 -0
  169. package/dist/mcp-server/tools/definitions/list-ad-accounts.tool.js +84 -0
  170. package/dist/mcp-server/tools/definitions/list-ad-accounts.tool.js.map +1 -0
  171. package/dist/mcp-server/tools/definitions/list-entities.tool.d.ts +165 -0
  172. package/dist/mcp-server/tools/definitions/list-entities.tool.d.ts.map +1 -0
  173. package/dist/mcp-server/tools/definitions/list-entities.tool.js +112 -0
  174. package/dist/mcp-server/tools/definitions/list-entities.tool.js.map +1 -0
  175. package/dist/mcp-server/tools/definitions/search-targeting.tool.d.ts +102 -0
  176. package/dist/mcp-server/tools/definitions/search-targeting.tool.d.ts.map +1 -0
  177. package/dist/mcp-server/tools/definitions/search-targeting.tool.js +98 -0
  178. package/dist/mcp-server/tools/definitions/search-targeting.tool.js.map +1 -0
  179. package/dist/mcp-server/tools/definitions/update-entity.tool.d.ts +104 -0
  180. package/dist/mcp-server/tools/definitions/update-entity.tool.d.ts.map +1 -0
  181. package/dist/mcp-server/tools/definitions/update-entity.tool.js +88 -0
  182. package/dist/mcp-server/tools/definitions/update-entity.tool.js.map +1 -0
  183. package/dist/mcp-server/tools/definitions/upload-image.tool.d.ts +75 -0
  184. package/dist/mcp-server/tools/definitions/upload-image.tool.d.ts.map +1 -0
  185. package/dist/mcp-server/tools/definitions/upload-image.tool.js +99 -0
  186. package/dist/mcp-server/tools/definitions/upload-image.tool.js.map +1 -0
  187. package/dist/mcp-server/tools/definitions/upload-video.tool.d.ts +69 -0
  188. package/dist/mcp-server/tools/definitions/upload-video.tool.d.ts.map +1 -0
  189. package/dist/mcp-server/tools/definitions/upload-video.tool.js +98 -0
  190. package/dist/mcp-server/tools/definitions/upload-video.tool.js.map +1 -0
  191. package/dist/mcp-server/tools/definitions/validate-entity.tool.d.ts +168 -0
  192. package/dist/mcp-server/tools/definitions/validate-entity.tool.d.ts.map +1 -0
  193. package/dist/mcp-server/tools/definitions/validate-entity.tool.js +200 -0
  194. package/dist/mcp-server/tools/definitions/validate-entity.tool.js.map +1 -0
  195. package/dist/mcp-server/tools/index.d.ts +2 -0
  196. package/dist/mcp-server/tools/index.d.ts.map +1 -0
  197. package/dist/mcp-server/tools/index.js +2 -0
  198. package/dist/mcp-server/tools/index.js.map +1 -0
  199. package/dist/mcp-server/tools/utils/entity-mapping.d.ts +13 -0
  200. package/dist/mcp-server/tools/utils/entity-mapping.d.ts.map +1 -0
  201. package/dist/mcp-server/tools/utils/entity-mapping.js +68 -0
  202. package/dist/mcp-server/tools/utils/entity-mapping.js.map +1 -0
  203. package/dist/mcp-server/tools/utils/media-types.d.ts +12 -0
  204. package/dist/mcp-server/tools/utils/media-types.d.ts.map +1 -0
  205. package/dist/mcp-server/tools/utils/media-types.js +2 -0
  206. package/dist/mcp-server/tools/utils/media-types.js.map +1 -0
  207. package/dist/mcp-server/tools/utils/resolve-session.d.ts +4 -0
  208. package/dist/mcp-server/tools/utils/resolve-session.d.ts.map +1 -0
  209. package/dist/mcp-server/tools/utils/resolve-session.js +6 -0
  210. package/dist/mcp-server/tools/utils/resolve-session.js.map +1 -0
  211. package/dist/mcp-server/transports/streamable-http-transport.d.ts +49 -0
  212. package/dist/mcp-server/transports/streamable-http-transport.d.ts.map +1 -0
  213. package/dist/mcp-server/transports/streamable-http-transport.js +91 -0
  214. package/dist/mcp-server/transports/streamable-http-transport.js.map +1 -0
  215. package/dist/services/linkedin/linkedin-http-client.d.ts +20 -0
  216. package/dist/services/linkedin/linkedin-http-client.d.ts.map +1 -0
  217. package/dist/services/linkedin/linkedin-http-client.js +147 -0
  218. package/dist/services/linkedin/linkedin-http-client.js.map +1 -0
  219. package/dist/services/linkedin/linkedin-reporting-service.d.ts +26 -0
  220. package/dist/services/linkedin/linkedin-reporting-service.d.ts.map +1 -0
  221. package/dist/services/linkedin/linkedin-reporting-service.js +69 -0
  222. package/dist/services/linkedin/linkedin-reporting-service.js.map +1 -0
  223. package/dist/services/linkedin/linkedin-service.d.ts +84 -0
  224. package/dist/services/linkedin/linkedin-service.d.ts.map +1 -0
  225. package/dist/services/linkedin/linkedin-service.js +195 -0
  226. package/dist/services/linkedin/linkedin-service.js.map +1 -0
  227. package/dist/services/linkedin/types.d.ts +166 -0
  228. package/dist/services/linkedin/types.d.ts.map +1 -0
  229. package/dist/services/linkedin/types.js +31 -0
  230. package/dist/services/linkedin/types.js.map +1 -0
  231. package/dist/services/session-services.d.ts +18 -0
  232. package/dist/services/session-services.d.ts.map +1 -0
  233. package/dist/services/session-services.js +16 -0
  234. package/dist/services/session-services.js.map +1 -0
  235. package/dist/types-global/mcp.d.ts +2 -0
  236. package/dist/types-global/mcp.d.ts.map +1 -0
  237. package/dist/types-global/mcp.js +2 -0
  238. package/dist/types-global/mcp.js.map +1 -0
  239. package/dist/utils/errors/index.d.ts +2 -0
  240. package/dist/utils/errors/index.d.ts.map +1 -0
  241. package/dist/utils/errors/index.js +2 -0
  242. package/dist/utils/errors/index.js.map +1 -0
  243. package/dist/utils/platform.d.ts +3 -0
  244. package/dist/utils/platform.d.ts.map +1 -0
  245. package/dist/utils/platform.js +5 -0
  246. package/dist/utils/platform.js.map +1 -0
  247. package/dist/utils/security/rate-limiter.d.ts +3 -0
  248. package/dist/utils/security/rate-limiter.d.ts.map +1 -0
  249. package/dist/utils/security/rate-limiter.js +5 -0
  250. package/dist/utils/security/rate-limiter.js.map +1 -0
  251. package/dist/utils/telemetry/index.d.ts +2 -0
  252. package/dist/utils/telemetry/index.d.ts.map +1 -0
  253. package/dist/utils/telemetry/index.js +2 -0
  254. package/dist/utils/telemetry/index.js.map +1 -0
  255. package/dist/utils/telemetry/tracing.d.ts +3 -0
  256. package/dist/utils/telemetry/tracing.d.ts.map +1 -0
  257. package/dist/utils/telemetry/tracing.js +4 -0
  258. package/dist/utils/telemetry/tracing.js.map +1 -0
  259. package/package.json +55 -0
package/LICENSE.md ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,304 @@
1
+ # @cesteral/linkedin-mcp
2
+
3
+ LinkedIn Ads MCP Server - Campaign management via LinkedIn Marketing API v2.
4
+
5
+ ## Purpose
6
+
7
+ Management server for LinkedIn Ads. Provides full CRUD operations, analytics
8
+ reporting, targeting discovery, bulk operations, and specialized features like
9
+ entity duplication and delivery forecasts. Designed for AI agents to manage
10
+ LinkedIn Ads campaigns programmatically through the Model Context Protocol with
11
+ per-session Bearer token authentication.
12
+
13
+ ## Features
14
+
15
+ - **Per-session Bearer token auth** via `LinkedInBearerAuthStrategy` (validates tokens against LinkedIn API)
16
+ - **Streamable HTTP + stdio transports** via Hono + `@hono/mcp`
17
+ - **OpenTelemetry** instrumentation for traces and metrics
18
+ - **Rate limiting** via shared `RateLimiter` class (100/min default, writes cost 3x)
19
+ - **Structured logging** via Pino
20
+ - **MCP Resources** for entity schemas, examples, analytics reference, and targeting reference
21
+ - **MCP Prompts** for campaign setup, analytics reporting, troubleshooting, and schema exploration
22
+
23
+ ## MCP Tools
24
+
25
+ ### Core CRUD
26
+
27
+ #### 1. `linkedin_list_entities`
28
+
29
+ List LinkedIn entities with optional filtering and offset-based pagination.
30
+
31
+ **Parameters:**
32
+
33
+ - `entityType` (string, required): Type of entity to list
34
+ - `adAccountUrn` (string, optional): Ad Account URN to scope results
35
+ - `start` (number, optional): Offset for pagination (default 0)
36
+ - `count` (number, optional): Results per page (default 25)
37
+
38
+ #### 2. `linkedin_get_entity`
39
+
40
+ Get a single LinkedIn entity by URN.
41
+
42
+ **Parameters:**
43
+
44
+ - `entityType` (string, required): Type of entity to retrieve
45
+ - `entityUrn` (string, required): The entity URN (e.g., `urn:li:sponsoredCampaign:123`)
46
+
47
+ #### 3. `linkedin_create_entity`
48
+
49
+ Create a new LinkedIn entity.
50
+
51
+ **Parameters:**
52
+
53
+ - `entityType` (string, required): Type of entity to create
54
+ - `data` (object, required): Entity fields as key-value pairs
55
+
56
+ #### 4. `linkedin_update_entity`
57
+
58
+ Update an existing LinkedIn entity (PATCH via Rest.li partial update).
59
+
60
+ **Parameters:**
61
+
62
+ - `entityType` (string, required): Type of entity to update
63
+ - `entityUrn` (string, required): The entity URN to update
64
+ - `data` (object, required): Fields to update as key-value pairs
65
+
66
+ #### 5. `linkedin_delete_entity`
67
+
68
+ Delete a LinkedIn entity.
69
+
70
+ **Parameters:**
71
+
72
+ - `entityType` (string, required): Type of entity to delete
73
+ - `entityUrn` (string, required): The entity URN to delete
74
+
75
+ ### Account
76
+
77
+ #### 6. `linkedin_list_ad_accounts`
78
+
79
+ List ad accounts accessible to the authenticated user.
80
+
81
+ **Parameters:**
82
+
83
+ - `start` (number, optional): Offset for pagination (default 0)
84
+ - `count` (number, optional): Number of accounts to return (default 25)
85
+
86
+ ### Analytics
87
+
88
+ #### 7. `linkedin_get_analytics`
89
+
90
+ Get delivery metrics for LinkedIn Ads entities via `/v2/adAnalytics`.
91
+
92
+ **Parameters:**
93
+
94
+ - `adAccountUrn` (string, required): Ad Account URN
95
+ - `startDate` (string, required): Start date (YYYY-MM-DD)
96
+ - `endDate` (string, required): End date (YYYY-MM-DD)
97
+ - `metrics` (string[], optional): Metrics to return (e.g., `impressions`, `clicks`, `costInUsd`)
98
+ - `pivot` (string, optional): Pivot dimension (e.g., `CAMPAIGN`, `CREATIVE`)
99
+
100
+ #### 8. `linkedin_get_analytics_breakdowns`
101
+
102
+ Get delivery metrics broken down by dimension (geo, device, member demographics, etc.).
103
+
104
+ **Parameters:**
105
+
106
+ - `adAccountUrn` (string, required): Ad Account URN
107
+ - `startDate` (string, required): Start date (YYYY-MM-DD)
108
+ - `endDate` (string, required): End date (YYYY-MM-DD)
109
+ - `pivots` (string[], required): Breakdown dimensions (e.g., `['MEMBER_COMPANY_SIZE', 'MEMBER_INDUSTRY']`)
110
+ - `metrics` (string[], optional): Metrics to return
111
+ - `datePreset` (string, optional): Date preset
112
+
113
+ ### Bulk Operations
114
+
115
+ #### 9. `linkedin_bulk_update_status`
116
+
117
+ Batch update status for multiple LinkedIn Ads entities.
118
+
119
+ **Parameters:**
120
+
121
+ - `entityType` (string, required): Type of entities to update
122
+ - `entityUrns` (string[], required): Entity URNs to update (max 50)
123
+ - `status` (string, required): `ACTIVE`, `PAUSED`, or `ARCHIVED`
124
+
125
+ #### 10. `linkedin_bulk_create_entities`
126
+
127
+ Batch create multiple entities of the same type.
128
+
129
+ **Parameters:**
130
+
131
+ - `entityType` (string, required): Type of entities to create
132
+ - `items` (array, required): Array of entity data objects (max 50)
133
+
134
+ #### 11. `linkedin_bulk_update_entities`
135
+
136
+ Batch update multiple entities with individual data payloads.
137
+
138
+ **Parameters:**
139
+
140
+ - `entityType` (string, required): Type of entities being updated
141
+ - `items` (array, required): Array of update items (max 50), each with `entityUrn` and `data`
142
+
143
+ #### 12. `linkedin_adjust_bids`
144
+
145
+ Batch adjust campaign bid amounts with percentage or absolute changes (safe read-modify-write).
146
+
147
+ **Parameters:**
148
+
149
+ - `adjustments` (array, required): Array of bid adjustments (max 50), each with campaign URN, `adjustmentType` (percentage/absolute), and `value`
150
+
151
+ ### Targeting
152
+
153
+ #### 13. `linkedin_search_targeting`
154
+
155
+ Search for targeting audience facets (skills, companies, locations, job titles) by keyword.
156
+
157
+ **Parameters:**
158
+
159
+ - `facetType` (string, required): Facet type to search (e.g., `skills`, `companies`, `locations`, `industries`)
160
+ - `query` (string, optional): Search keyword
161
+ - `limit` (number, optional): Max results (default 25)
162
+
163
+ #### 14. `linkedin_get_targeting_options`
164
+
165
+ Browse available targeting categories for an ad account.
166
+
167
+ **Parameters:**
168
+
169
+ - `adAccountUrn` (string, required): Ad Account URN
170
+ - `facetType` (string, optional): Filter by facet type
171
+
172
+ ### Specialized
173
+
174
+ #### 15. `linkedin_duplicate_entity`
175
+
176
+ Duplicate a campaign group, campaign, or creative.
177
+
178
+ **Parameters:**
179
+
180
+ - `entityType` (string, required): Type of entity to duplicate (`campaignGroup`, `campaign`, `creative`)
181
+ - `entityUrn` (string, required): URN of the entity to duplicate
182
+ - `options` (object, optional): Duplication options (e.g., rename prefix/suffix, status)
183
+
184
+ #### 16. `linkedin_get_delivery_forecast`
185
+
186
+ Get audience size and delivery forecast for a targeting configuration.
187
+
188
+ **Parameters:**
189
+
190
+ - `adAccountUrn` (string, required): Ad Account URN
191
+ - `targetingCriteria` (object, required): Targeting criteria specification
192
+
193
+ #### 17. `linkedin_get_ad_preview`
194
+
195
+ Get ad preview rendering for a creative.
196
+
197
+ **Parameters:**
198
+
199
+ - `creativeUrn` (string, required): Creative URN to preview
200
+ - `adFormat` (string, optional): Ad format for preview rendering
201
+
202
+ ### Validation
203
+
204
+ #### 18. `linkedin_validate_entity`
205
+
206
+ Client-side validation of entity payloads without making API calls.
207
+
208
+ **Parameters:**
209
+
210
+ - `entityType` (string, required): Type of entity to validate
211
+ - `mode` (string, required): Validation mode (`create` or `update`)
212
+ - `data` (object, required): Entity data to validate
213
+
214
+ ## Supported Entity Types
215
+
216
+ | Entity Type | API Object | Notes |
217
+ | ---------------- | --------------- | ---------------------------------------------------------- |
218
+ | `adAccount` | Ad Account | Top-level advertising account |
219
+ | `campaignGroup` | Campaign Group | Groups campaigns for budget and scheduling |
220
+ | `campaign` | Campaign | Targeting, bidding, budget, objective |
221
+ | `creative` | Creative | Ad creative content (sponsored content, message ads, etc.) |
222
+ | `conversionRule` | Conversion Rule | Conversion tracking rules for attribution |
223
+
224
+ **Entity Hierarchy:** Ad Account > Campaign Group > Campaign > Creative (+ Conversion Rules)
225
+
226
+ ## Current Status
227
+
228
+ **Phase: Production-Ready**
229
+
230
+ All listed tools are fully implemented using LinkedIn Marketing API v2 with
231
+ Bearer token authentication, analytics reporting, and targeting discovery.
232
+
233
+ ## Development
234
+
235
+ ```bash
236
+ # Install dependencies
237
+ pnpm install
238
+
239
+ # Run in development mode
240
+ pnpm run dev:http
241
+
242
+ # Build
243
+ pnpm run build
244
+
245
+ # Start production server
246
+ pnpm run start
247
+
248
+ # Type check
249
+ pnpm run typecheck
250
+ ```
251
+
252
+ ## Environment Variables
253
+
254
+ - `LINKEDIN_MCP_PORT`: Server port (default: 3006)
255
+ - `LINKEDIN_MCP_HOST`: Server host (default: `127.0.0.1` in development, `0.0.0.0` in production)
256
+ - `MCP_AUTH_MODE`: Authentication mode - `linkedin-bearer` (default), `jwt`, or `none`
257
+ - `MCP_AUTH_SECRET_KEY`: Required when `MCP_AUTH_MODE=jwt`
258
+ - `LINKEDIN_API_BASE_URL`: LinkedIn API base URL (default: `https://api.linkedin.com`)
259
+ - `LINKEDIN_API_VERSION`: API version header value (default: `202409`)
260
+ - `LINKEDIN_RATE_LIMIT_PER_MINUTE`: Rate limit ceiling (default: 100)
261
+ - `LINKEDIN_ACCESS_TOKEN`: Access token for stdio mode
262
+
263
+ ## Architecture
264
+
265
+ ### Key Components
266
+
267
+ - **`LinkedInHttpClient`** - HTTP client for LinkedIn Marketing API v2 with versioned headers
268
+ - **`LinkedInService`** - CRUD, bulk ops, duplication, targeting, delivery forecasts, ad previews
269
+ - **`LinkedInReportingService`** - Analytics queries with breakdowns and pivots
270
+ - **`LinkedInBearerAuthStrategy`** - Bearer token auth via LinkedIn API validation
271
+ - **`LinkedInAuthAdapter`** - Token management for per-session API calls
272
+ - **`SessionServiceStore`** - Per-session service instances keyed by session ID
273
+
274
+ ### Key Gotchas
275
+
276
+ - Entity identifiers use **URN format** (e.g., `urn:li:sponsoredCampaign:123`)
277
+ - `LinkedIn-Version: 202409` header is **required on all API requests** and injected automatically
278
+ - Updates use **Rest.li partial update format** via `X-Restli-Method: PARTIAL_UPDATE`
279
+ - Budget values are `CurrencyAmount` objects with `currencyCode` and `amount` (amount is in **cents**)
280
+ - `ARCHIVED` status is **permanent** and cannot be reversed
281
+
282
+ ### Transport
283
+
284
+ Streamable HTTP via Hono + `@hono/mcp`. Health check at `/health`.
285
+
286
+ ## Contributing
287
+
288
+ See root [CLAUDE.md](../../CLAUDE.md) for development guidelines, build system details, and monorepo conventions. See the [root README](../../README.md) for full architecture context.
289
+
290
+ ---
291
+
292
+ ## Get Started
293
+
294
+ **Self-host**: Follow the [deployment guide](../../docs/guides/deployment-instructions.md) to run this server on your own infrastructure.
295
+
296
+ **Cesteral Intelligence**: [Request access](https://cesteral.com/integrations/linkedin-ads?utm_source=github&utm_medium=package-readme&utm_campaign=linkedin-mcp) -- governed execution with credential brokering, approvals, audit, and multi-tenant access.
297
+
298
+ **Book a workflow demo**: [See it in action](mailto:sales@cesteral.com?subject=Workflow%20demo%20-%20LinkedIn%20Ads%20MCP) with your own ad accounts.
299
+
300
+ **Compare options**: [OSS connectors vs Cesteral Intelligence](https://cesteral.com/compare?utm_source=github&utm_medium=package-readme&utm_campaign=linkedin-mcp)
301
+
302
+ ## License
303
+
304
+ Apache License 2.0 — see [LICENSE](../../LICENSE.md) for details. This package is part of Cesteral's open-source connector layer; managed hosting and higher-level governance features live outside this repository.
@@ -0,0 +1,3 @@
1
+ export * from "./linkedin-auth-adapter.js";
2
+ export * from "./linkedin-auth-strategy.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAGA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./linkedin-auth-adapter.js";
2
+ export * from "./linkedin-auth-strategy.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAGA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { OAuth2RefreshAdapterBase } from "@cesteral/shared";
2
+ export interface LinkedInAuthAdapter {
3
+ getAccessToken(): Promise<string>;
4
+ validate(): Promise<void>;
5
+ readonly personId: string;
6
+ }
7
+ export declare class LinkedInAccessTokenAdapter implements LinkedInAuthAdapter {
8
+ private readonly accessToken;
9
+ private readonly baseUrl;
10
+ private readonly apiVersion;
11
+ private validated;
12
+ private _personId;
13
+ constructor(accessToken: string, baseUrl?: string, apiVersion?: string);
14
+ get personId(): string;
15
+ getAccessToken(): Promise<string>;
16
+ validate(): Promise<void>;
17
+ }
18
+ export interface LinkedInRefreshCredentials {
19
+ clientId: string;
20
+ clientSecret: string;
21
+ refreshToken: string;
22
+ }
23
+ export declare class LinkedInRefreshTokenAdapter extends OAuth2RefreshAdapterBase<{
24
+ appId: string;
25
+ appSecret: string;
26
+ refreshToken: string;
27
+ }> implements LinkedInAuthAdapter {
28
+ private readonly baseUrl;
29
+ private readonly apiVersion;
30
+ private _personId;
31
+ constructor(credentials: LinkedInRefreshCredentials, baseUrl?: string, apiVersion?: string);
32
+ get personId(): string;
33
+ validate(): Promise<void>;
34
+ }
35
+ export declare function parseLinkedInTokenFromHeaders(headers: Record<string, string | string[] | undefined>): string;
36
+ export declare function parseLinkedInRefreshCredentialsFromHeaders(headers: Record<string, string | string[] | undefined>): LinkedInRefreshCredentials | undefined;
37
+ export declare function getLinkedInCredentialFingerprint(accessToken: string): string;
38
+ //# sourceMappingURL=linkedin-auth-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linkedin-auth-adapter.d.ts","sourceRoot":"","sources":["../../src/auth/linkedin-auth-adapter.ts"],"names":[],"mappings":"AAeA,OAAO,EAML,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAK1B,MAAM,WAAW,mBAAmB;IAClC,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAwCD,qBAAa,0BAA2B,YAAW,mBAAmB;IAKlE,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAN7B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAM;gBAGJ,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,MAAmC,EAC5C,UAAU,GAAE,MAAiB;IAGhD,IAAI,QAAQ,IAAI,MAAM,CAErB;IAEK,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAIjC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAKhC;AAKD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB;AAUD,qBAAa,2BACX,SAAQ,wBAAwB,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAC3F,YAAW,mBAAmB;IAM5B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAL7B,OAAO,CAAC,SAAS,CAAM;gBAGrB,WAAW,EAAE,0BAA0B,EACtB,OAAO,GAAE,MAAmC,EAC5C,UAAU,GAAE,MAAiB;IAsDhD,IAAI,QAAQ,IAAI,MAAM,CAErB;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAIhC;AAMD,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GACrD,MAAM,CAgBR;AAMD,wBAAgB,0CAA0C,CACxD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GACrD,0BAA0B,GAAG,SAAS,CAUxC;AAKD,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE5E"}
@@ -0,0 +1,110 @@
1
+ import { extractHeader, fetchWithTimeout, fingerprintCredentials, JsonRpcErrorCode, McpError, OAuth2RefreshAdapterBase, } from "@cesteral/shared";
2
+ async function fetchLinkedInPersonId(token, baseUrl, apiVersion) {
3
+ const response = await fetchWithTimeout(`${baseUrl}/v2/me?projection=(id,vanityName)`, 10_000, undefined, {
4
+ headers: {
5
+ Authorization: `Bearer ${token}`,
6
+ "LinkedIn-Version": apiVersion,
7
+ "X-Restli-Protocol-Version": "2.0.0",
8
+ },
9
+ });
10
+ if (!response.ok) {
11
+ const errorBody = await response.text().catch(() => "");
12
+ throw new McpError(JsonRpcErrorCode.Unauthorized, `LinkedIn token validation failed: ${response.status} ${response.statusText}. ${errorBody.substring(0, 200)}`);
13
+ }
14
+ const data = (await response.json());
15
+ return data.id;
16
+ }
17
+ export class LinkedInAccessTokenAdapter {
18
+ accessToken;
19
+ baseUrl;
20
+ apiVersion;
21
+ validated = false;
22
+ _personId = "";
23
+ constructor(accessToken, baseUrl = "https://api.linkedin.com", apiVersion = "202409") {
24
+ this.accessToken = accessToken;
25
+ this.baseUrl = baseUrl;
26
+ this.apiVersion = apiVersion;
27
+ }
28
+ get personId() {
29
+ return this._personId;
30
+ }
31
+ async getAccessToken() {
32
+ return this.accessToken;
33
+ }
34
+ async validate() {
35
+ if (this.validated)
36
+ return;
37
+ this._personId = await fetchLinkedInPersonId(this.accessToken, this.baseUrl, this.apiVersion);
38
+ this.validated = true;
39
+ }
40
+ }
41
+ export class LinkedInRefreshTokenAdapter extends OAuth2RefreshAdapterBase {
42
+ baseUrl;
43
+ apiVersion;
44
+ _personId = "";
45
+ constructor(credentials, baseUrl = "https://api.linkedin.com", apiVersion = "202409") {
46
+ super({
47
+ platformName: "LinkedIn",
48
+ credentials: {
49
+ appId: credentials.clientId,
50
+ appSecret: credentials.clientSecret,
51
+ refreshToken: credentials.refreshToken,
52
+ },
53
+ requestToken: async (refreshToken) => {
54
+ const params = new URLSearchParams({
55
+ grant_type: "refresh_token",
56
+ refresh_token: refreshToken,
57
+ client_id: credentials.clientId,
58
+ client_secret: credentials.clientSecret,
59
+ });
60
+ const response = await fetchWithTimeout("https://www.linkedin.com/oauth/v2/accessToken", 10_000, undefined, {
61
+ method: "POST",
62
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
63
+ body: params.toString(),
64
+ });
65
+ if (!response.ok) {
66
+ const errorBody = await response.text().catch(() => "");
67
+ throw new McpError(JsonRpcErrorCode.InternalError, `LinkedIn token refresh failed: ${response.status} ${response.statusText}. ${errorBody.substring(0, 200)}`);
68
+ }
69
+ const data = (await response.json());
70
+ if (!data.access_token) {
71
+ throw new McpError(JsonRpcErrorCode.InternalError, "LinkedIn token refresh returned no access_token");
72
+ }
73
+ return data;
74
+ },
75
+ });
76
+ this.baseUrl = baseUrl;
77
+ this.apiVersion = apiVersion;
78
+ }
79
+ get personId() {
80
+ return this._personId;
81
+ }
82
+ async validate() {
83
+ const token = await this.getAccessToken();
84
+ this._personId = await fetchLinkedInPersonId(token, this.baseUrl, this.apiVersion);
85
+ }
86
+ }
87
+ export function parseLinkedInTokenFromHeaders(headers) {
88
+ const authHeader = extractHeader(headers, "authorization");
89
+ if (!authHeader) {
90
+ throw new McpError(JsonRpcErrorCode.Unauthorized, "Missing required Authorization header");
91
+ }
92
+ const match = authHeader.match(/^Bearer\s+(.+)$/i);
93
+ if (!match || !match[1]) {
94
+ throw new McpError(JsonRpcErrorCode.Unauthorized, "Authorization header must use Bearer scheme");
95
+ }
96
+ return match[1];
97
+ }
98
+ export function parseLinkedInRefreshCredentialsFromHeaders(headers) {
99
+ const clientId = extractHeader(headers, "x-linkedin-client-id");
100
+ const clientSecret = extractHeader(headers, "x-linkedin-client-secret");
101
+ const refreshToken = extractHeader(headers, "x-linkedin-refresh-token");
102
+ if (!clientId || !clientSecret || !refreshToken) {
103
+ return undefined;
104
+ }
105
+ return { clientId, clientSecret, refreshToken };
106
+ }
107
+ export function getLinkedInCredentialFingerprint(accessToken) {
108
+ return fingerprintCredentials(accessToken);
109
+ }
110
+ //# sourceMappingURL=linkedin-auth-adapter.js.map